当前位置 : 主页 > 手机开发 > 其它 >

继承性问题

来源:互联网 收集:自由互联 发布时间:2021-06-19
1.对象的继承 var 新对象=object.create(被继承的对象) 新对象.__proto__==被继承的对象 2.函数的继承 script function Person(name,age){ this .name= name; this .age= age;}function Student(name,age,score){ Person.call( t

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}

网友评论