T
timothytoe
I understand JavaScript objects well enough to make objects and add
prototype functions to them later on.
Despite my success in getting programs written, I keep coming back to
Crockford's paper on prototypal inheritance, in which he decides that
all that work he did earlier to bolt a classical inheritance system
onto JavaScript was missing the point.
http://javascript.crockford.com/prototypal.html
It's an interesting paper, but he just drops a couple functions on us
and acts as if anyone reading the paper should go ahhh! I've read the
paper many times and the point eludes me. Just what do these functions
give me that I don't already have?
function object(o) {
function F() {}
F.prototype = o;
return new F();
}
and
Object.prototype.begetObject = function () {
function F() {}
F.prototype = this;
return new F();
};
newObject = oldObject.begetObject();
I'm assuming that if I saw an example of one in use, I'd get that
elusive aha feeling.
Can someone please explain the clever bits? Or give me an example and
explain how the example is helped by the function.
He even drops one of these into a Powerpoint slideshow he has. One its
own slide. All alone. As if it requires no explanation.
If you were planning to help a dolt or a dope understand one thing
today, let that dope be me, and let that thing be this.
prototype functions to them later on.
Despite my success in getting programs written, I keep coming back to
Crockford's paper on prototypal inheritance, in which he decides that
all that work he did earlier to bolt a classical inheritance system
onto JavaScript was missing the point.
http://javascript.crockford.com/prototypal.html
It's an interesting paper, but he just drops a couple functions on us
and acts as if anyone reading the paper should go ahhh! I've read the
paper many times and the point eludes me. Just what do these functions
give me that I don't already have?
function object(o) {
function F() {}
F.prototype = o;
return new F();
}
and
Object.prototype.begetObject = function () {
function F() {}
F.prototype = this;
return new F();
};
newObject = oldObject.begetObject();
I'm assuming that if I saw an example of one in use, I'd get that
elusive aha feeling.
Can someone please explain the clever bits? Or give me an example and
explain how the example is helped by the function.
He even drops one of these into a Powerpoint slideshow he has. One its
own slide. All alone. As if it requires no explanation.
If you were planning to help a dolt or a dope understand one thing
today, let that dope be me, and let that thing be this.