我提到this问题/答案,以了解原型继承。 我知道要扩展一个方法,我们需要在基类中定义Person.prototype.getName。因此,在子类可以在答案被称为myCustomer.sayMyName(); 代码可以概括如下: function Customer(name) {
this.firstName = name;
};
function U
请参考给定的例子: 代码: var Person = function (name) {
this.name = name;
}
var john = new Person("John");
console.log(Person.prototype);//Object{}
console.log(john.prototype); //undefined
人如此它的原型会从对象
在我的业余时间,我尝试学习一点JS,但我坚持主题的主题。 var person = new Person("Bob", "Smith", 52);
var teacher = new Teacher("Adam", "Greff", 209);
function Humans(firstName, lastName) {
this.firstName = first