[javascript mode] Properly handle commas

Closes #1433