Lets suppose I made a class called Person.
var Person = function(fname){this.fname = fname;};
pObj is the object I made from this class.
var pObj = new Person('top');
now I add one property to Person class, say lname.
Person.prototype.lname = "Thomsom";
now pObj.lname gets me “Thomson”.
My question is that, when pObj didn’t find the property lname in it, how does it know where to look for.
Every object has a prototype. When a properti is not set for object instance, it is looked in object’s prototype. In Gecko and WebKit, you can use object’s
__proto__property to get (or set) reference to its prototype.You can get object prototype using standard
myObj.constructor.prototype