JS: Utility Function in a Closure