Here i have two constructor say First and Second.
First inherits from Second.First also has a hair property on its prototype chain.
A newly created object say tom which supposed to be an instance of First constructor has also a user-defined property called nail.
If i want to log all the enumerable properties of tom object using a for...in loop it only shows name,nail and age.But hair property seems to be disappeared from its prototype chain.
Why hair property disappeared from the prototype chain?? How can i get it back??
<html>
<body>
<script>
function First(name){
this.name=name;
}
First.prototype.hair='black';// tom.hair gets me undefined
function Second(){
this.age=1;
}
First.prototype=new Second();
var tom=new First('tom');
tom.nail='sharp';// added property to tom
for(var i in tom){
console.log(i);
}
console.log(tom.hair);
</script>
</body>
</html>