how does an object knows about its parent in javascript
Posted
by alter
on Stack Overflow
See other posts from Stack Overflow
or by alter
Published on 2010-05-14T10:38:24Z
Indexed on
2010/05/14
10:44 UTC
Read the original article
Hit count: 174
JavaScript
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.
© Stack Overflow or respective owner