继承性问题

1.对象的继承

var 新对象=object.create(被继承的对象)

新对象.__proto__==被继承的对象

2.函数的继承

<script>
function Person(name,age){
  this.name=name;
  this.age=age;
}
function Student(name,age,score){
  Person.call(this,name,age);
  this.score=score
}
var zs=new Student('zs',15,95)
console.log(zs)
</script>

打印结果:Student {name: "zs", age: 15, score: 95}

猜你喜欢

转载自www.cnblogs.com/zhaodz/p/11593922.html
今日推荐