D
dylan m. austin
Here's a couple of blog posts. I'm surprised that no-one have mentioned
John Resig's yet.
Why? Comic relief?
[snip]
Hehe, I don't know why I get a kick of out of the resig-bashing. It's
probably not the best of behavior.
I too haven't been following the latest work on the ECMAScript
specifications but here's one entry I found interesting on Johh's
blog:
http://ejohn.org/blog/objectgetprototypeof/
It covers the Object.getPrototypeOf method they've come up with for
ECMAScript 3.1 and shows a basic example of getting super-
functionality with it. I'll reproduce that here:
function Person(){}
Person.prototype.kick = function(type){
alert(type + " kick!");
}
function Norris(){}
// Inherit properties from Person
Norris.prototype = new Person();
Norris.prototype.kick = function(){
Object.getPrototypeOf(this).kick("Roundhouse");
};
His example isn't dependent on correct binding of the 'super' call.
For a more real-world use it would probably need the use of 'call',
like so:
Norris.prototype.kick = function(){
Object.getPrototypeOf(this).kick.call(this,"Roundhouse");
};
So how about that, David? You can use call and avoid constructor
reference clumsiness. Pretty super or what? If you are coding for 3.1
and up implementations, anyway.