Inheritance issues

1. inherited objects

var new object = object.create (inherited object)

New object .__ proto __ == inherited objects

2. Functions of inheritance

<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>

Print Results: Student {name: "zs", age: 15, score: 95}

 

Guess you like

Origin www.cnblogs.com/zhaodz/p/11593922.html