A command-line interface for JavaScript and DOM.
Open the shell or get the Shell bookmarklet.
b = document.bodyfunction f() { return 5; } or function f() 5; in JavaScript 1.8Please note: Hotkeys (the "Alt+Key" codes) may also require you to push the Shift key on Linux.
ans: the result of the previous expression.print(expr): prints expr on its own line. If passed mutiple arguments, they will all be printed on one line as an array joined by ", "
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 }load(scriptURI [, printLoadMessage [, forcedVersion]]): loads a JavaScript script. printLoadMessage and forcedVersion are optional. printLoadMessage defaults to true and determines if a loading message should be displayed. forcedVersion defaults to the current JavaScript version and determines the version of JavaScript a script should be run under.
load("http://example.com/foo.js", false, 1.8)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.JSON.stringify(object) or Alt+J: creates a JSON representation of an object.
JSON.stringify({foo: "bar", id: 9814})JSON.parse(JSON string): parses a JSON string and returns an object.
JSON.parse('{"foo":"bar","id":9814}')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, Jesper Rønn-Jensen fixed a few bugs for 1.4, and Elijah Grey added JSON support, enhanced print(), and latest JavaScript version evaling in 1.4 Extended. Changelogs for some versions are available. The JavaScript Shell is GPL/LGPL/MPL tri-licensed.
Last modified October 11, 2009.