https://developer.mozilla.org/en/introduction_to_the_javascript_shell
https://developer.mozilla.org/en/JavaScript/Shells
The JavaScript shell is a command-line program included in the SpiderMonkey source distribution. It is the JavaScript equivalent of Python's interactive prompt, the Lisp read-eval-print loop, or Ruby's irb
. This article explains how to use the shell to experiment with JavaScript code and run JavaScript programs.
To get the SpiderMonkey JavaScript shell, see the SpiderMonkey Build Documentation or download a compiled binary for your platform from the Nightly Builds.
For a list of other JavaScript shells, see JavaScript shells.
Using the JavaScript shell
The shell offers two modes of operation. You can use it as an interactive shell, in which you type JavaScript code at a prompt and get instant gratification, which is handy for experimenting or testing new features. You can also pass in, on the command line, a JavaScript program file to run, in which case the program is run automatically.