[javascript mode] Handle getter/setter definitions better

Closes #1336