Peter Michaux wrote:
What happens if you do this?
function Person() {}
Person.prototype = 7;
var ted = new Person();
See ECMA 262, 3rd Ed. Section 13.2.2
If the - prototype - property of a function that is used as a constructor
is not an object (of the ECMAScript Object type) then the original value
of - Object.prototype - is used to set the [[Prototype]] if the objects
constructed.
Also what happens if you set Person.prototype to an array
or function?
Functions and Arrays are objects so they will be used as the
[[Prototype]] of the newly constructed object, and it will inherit their
properties and methods.
Richard.