function Person(name){
this.name = name;
}
Person.prototype.greet = function(otherName){
return "Hi " + otherName + ", my name is " + name;
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这跟继承没得关系,
greet是原型方法,Person对象可以使用的,但是里面对name的引用错了,需要加this.。