javascript: tiny APPLY refactoring