Tue, 26 Apr 2005:
The major problem most people have with Javascript is that there is no easy way to test your code outside the browser. Often it so happens that you might want to test out a string split or array splice quickly. Here's a quick tip on getting a python'ish javascript shell.
/usr/lib/firefox-1.0/run-mozilla.sh /usr/lib/firefox-1.0/xpcshellThis should give you something like
js> a = [42, "is" , "the" , "answer"] 42,is,the,answer js> a.sort() 42,answer,is,theYou can run your javascript code like this and pretty much everything outside the DOM and Window stuff can be well tested. And lastly the ultimate javascript hack of all time - Object orientation.
function base() { } base.prototype.myname = function () { return "I am base"; } function derieved() { this.base = base; this.base(); } derieved.prototype = new base; derieved.prototype.__myname = derieved.prototype.myname; derieved.prototype.myname = function () { return "I am derieved"; } print(new derieved().myname()); print(new derieved().__myname());