The amazing Javascript
... never ceases to amaze me!
In all ways (including time) this:
var Foos = { One:0, Two:0 } ;
Foos.Speak = function()
{
return ( this.One + " : " + this.Two ) ;
}
var s = Foos.Speak() + "\n"
+ ( Foos.One + " : " + Foos.Two ) + "\n"
+ ( Foos["One"] + " : " + Foos["Two"] ) ;
alert( s ) ;
... is the direct equivalent of this:
function Bars()
{
this.One = this.Two = 0 ;
}
Bars.prototype.Speak = function()
{
return ( this.One + " : " + this.Two ) ;
}
bars = new Bars() ;
alert( bars.Speak() ) ;
UPDATE: Andy did the research! [ http://weblogs.asp.net/asmith/posts/28643.aspx ]