function Parent(name) {
this.name = name;
}
Parent.prototype.sayHello = function() {
return 'Hello, '+ this.name;
};
function Child(name, age) {
Parent.call(this, name);
this.age = age;
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
var child = new Child('Alice', 10);
console.log(child.sayHello());
上面这段代码打印的结果是什么()
