[javascript mode] Handle non-typical for-initializers properly

Closes #1418