(from my code) I wonder the Person's prototype that gives inheritance for its child. I know that 'Programmer object(?)' inherit the Person's 'introduce' property. but I'm not sure that 'Programmer' inherit the Person's 'name' and 'age' property. In Chrome console, It looks that Programmer inherit the Person's 'name',,, But, In my memory, My teacher said that doesn't inherit the Person's 'name'property........
What is true???? (I can distinguish '[[prototype]]' and 'prototype property') But I'm not sure that what does engage in a prototype that something can inherit and what does not engage in prototype,
/////////////////////
in
function X(){
this.Z = null;
};
X.prototype.Y = null;
X's child inherit 'Y', but not Z
Is this right??
(Sorry I'm not a native English speaker,,,,)
//it's my code
<script>
function Person(name, age){
this.name = name;
this.age =age;
}
Person.prototype.introduce = function(){
console.log("My name is "+this.name);
}
function Programmer(){
this.coding = function(){
console.log("I can code up");
}
}
Programmer.prototype = new Person("XX", 19);
</script>