Sneaky Abstractions

Subscribe to my Feed, follow me on , recommend me on Working With Rails or see my code on GitHub

IRB for JavaScript

Posted on May 09, 2007 10:47, 3 comments. Tagged with irb, javascript, spidermonkey.

Have you ever wished there was a console application for JavaScript, like IRB for Ruby, where you can try things out? Well, there is one and it is part of Mozilla’s SpiderMonkey JavaScript implementation (in C). If you’re on Ubuntu (and maybe Debian too?), installing it is as easy as

apt-get install spidermonkey-bin

Then, run js:

js> Foo = function(){}
function () {
}
js> Foo.prototype.bar = function(){ print('BAR!') }
function () {
    print("BAR!");
}
js> foo = new Foo()
[object Object]
js> foo.bar()
BAR!

This may be something that everyone else but me knew about, but I’m pretty excited to have somewhere other than a browser to try out things as I start learning JavaScript properly.

Comments

Atom feed

By John Nunemaker at

You can also use firebug with firefox. It has a console for testing js stuff.

By Phil at

Sweet; this is the missing link for stuff that MozRepl is overkill for. Sometimes you just don’t need the chrome overhead.

http://dev.hyperstruct.net/mozlab/wiki/MozRepl

By kangax at

Nice. I wonder if there are any wrappers for spidermonkey to work with applescript/ruby/etc.

Leave a comment

OpenID

Or..

Old school

There's always money in the banana stand!!