什么是继承
function parent(){
this.name="fangdown";
}
function child(){
this.age ="30";
}
child.prototype = new parent();
var test = new child();
console.log(test.name);
输出fangdown
个人理解的意思就是 两个函数。可以通过继承的方式,如何继承(通过prototype),将被继承的函数中的变量获取到
什么是继承
function parent(){
this.name="fangdown";
}
function child(){
this.age ="30";
}
child.prototype = new parent();
var test = new child();
console.log(test.name);
输出fangdown
个人理解的意思就是 两个函数。可以通过继承的方式,如何继承(通过prototype),将被继承的函数中的变量获取到