<script>

1)创建父类

 

function Person(){

 }
Person.prototype.age = 18;//给父类添加属性
var p1 = new Person();//给父类添加方法

 

2)创建子类

 

function Child(){

}

 

3)确定继承关系

 

Child.prototype = Object.create(Person.prototype);
Child.prototype.stuno = "2000";

 

4)改造构造器(不是很重要)

</script>

 

相关文章:

  • 2021-04-28
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-12-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-17
  • 2021-07-15
  • 2022-01-19
  • 2021-10-13
  • 2022-12-23
  • 2021-08-06
相关资源
相似解决方案