[JS] Refactoring