JavaScript refactorings