A command-line interface for JavaScript and DOM.
Open the shell or get the Shell bookmarklet (Firefox only).
b = document.body
function f() { return 5; }
ans
: the result of the previous expression.print(expr)
: prints expr on its own line.
for(i = 0; i < 6; ++i) print(i * i)
pr(expr)
: prints and returns its input, so you can use it to print intermediate results in the middle of an expression.
function fact(n) { return n>0 ? pr(n*fact(n-1)) : 1 }
blink(node)
or Alt+B: makes a node blink for a second.
blink(document.links[3])
props(obj)
or Alt+P: lists the methods and fields of an object.
props(document.body)
props
also shows which properties belong to the object itself and which belong to objects in its prototype chain.document.body
using props
(Alt+P) to figure out what is possible.sin
and pow
.The JavaScript shell was created by Jesse Ruderman. Ted Mielczarek added the tab completion feature in 1.1, Edward Lee added the multiline input feature in 1.2, and Jesper Rønn-Jensen fixed a few bugs for 1.4. Changelogs for some versions are available. The JavaScript Shell is GPL/LGPL/MPL tri-licensed.
Last modified October 30, 2005.