Object.prototype[‘new’]=function(){
var params=[];
var argc=arguments.length;
for(var i=0;i<argc;i++){
params.push(‘arguments[’+i+’]’);
}
var code=‘return new this(’+params.join(’,’)+’);’;
return new Function(code).apply(this,arguments);
}
There seems to be a javascript toolkit with ruby-style syntax …
Out of the sandbox ?
Few people know that on windows, if you rename .html to .hta, then
javascript will gain the ability of accessing filesystem, spawning
process, even calling DirectX. So you can write fully-featured gui
programs in javascript with notepad, without install anything else …
Another popular javascript tool is Rhino, which is cross-platform.
Javascript is indeed a fine language - but as you’re probably aware,
this is the ruby-talk mailing list. Is your point that you can do
Ruby-like things in Javascript? Sure can.
Javascript might be a great general-purpose language if it weren’t so
sandboxed. That is, whilst you can get a Javascript interpreter which
runs on the command line (spidermonkey), it can’t talk to the filesystem
or spawn external processes.