CS242 | |||||||
| |||||||
SpiderMonkey is the JavaScript engine used in Firefox 2.0. On this page, you can download the SpiderMonkey engine as a stand-alone JavaScript shell.
To download the JavaScript shell, download the SpiderMonkey executable and the Cygwin DLL to the same folder.
To download the JavaScript shell, download the SpiderMonkey zip file and extract the executable.
To run the shell, double-click js.exe. If you see the error
message "This application has failed to start because cygwin1.dll was
not found.", be sure the Cygwin DLL is in
the same folder as js.exe. You should now see the following
prompt:
js>Try typing the following commands:
js> function f(x) { return x + 5; }
js> f(7);
12
js> function curriedAdd(x) { return function(y) { return x + y; } }
js> var h = curriedAdd(3);
js> h(4);
7
js> quit();
The SpiderMonkey shell has a number of useful built-in functions. The
function help(); prints a list. Listed below are a few that
are particularly instructive:
Command Usage Description ======= ===== =========== print print([exp ...]) Evaluate and print expressions help help([name ...]) Display usage and help messages quit quit() Quit the shell dis dis([fun]) Disassemble functions into bytecodes dissrc dissrc([fun]) Disassemble functions with source