function Person1(){
this.name='Person1 Name';
this.Age='Person1 Age';
this.Sex='Person1 Sex';
}
Person1.prototype.getInfo=function(){
return this.name;
}
var Person2=Object.create(Person1.prototype);
console.log(Person2.getInfo());
Я хочу, чтобы выход как Person1 Name by Inheritance, Каковы способы его достижения. Здесь я хотел бы знать, что содержит Person2? каковы разные Пути?Как получить доступ к прототипу метода
'Person2.prototype.getInfo()'? – elclanrs
Person2.prototype.getInfo() Он ничего не делает, просто возвращает ничего – Curious
, конечно, потому что Person2 не имеет свойства имени. 'Person2.name = 'Person2 Name''; затем 'Person2.getInfo()' – RomanPerekhrest