There's code for it on Git-Hub. You'd just have to copy the whole thing into JavaScript.
There's a project on Github which is supposed to convert Quest to JS; but as far as I'm aware it was last updated when Quest 5.7 was current, and didn't support all the built-in functions. So it'll work with some games, more likely if you use only the most basic functions.