J
Jeff Stewart
I'm curious about some of the machinery behind prototypal inheritance.
What's going on under JavaScript's hood that prevents me from assigning
properties to the prototype of an Object proper, rather than a
Function?
That is, why am I able to assign an object to a function's prototype
like so,
var f = function() {}
f.prototype = new BaseObject();
but the same procedure doesn't work (results in a meaningless
"prototype" key in the 'o' hash) in the usage below?
var o = new Object();
o.prototype = new BaseObject();
What's going on under JavaScript's hood that prevents me from assigning
properties to the prototype of an Object proper, rather than a
Function?
That is, why am I able to assign an object to a function's prototype
like so,
var f = function() {}
f.prototype = new BaseObject();
but the same procedure doesn't work (results in a meaningless
"prototype" key in the 'o' hash) in the usage below?
var o = new Object();
o.prototype = new BaseObject();