js类继承

来源:互联网 发布:stm32编程 编辑:程序博客网 时间:2024/06/02 21:15

1.对象冒充

2.call

3.apply

4.prototype

function father(){}

function sun(){}

sun.prototype=new father();//子类产生的对象都会有父类中的属性

sun.prototype.constructor=sun();//由于上一句造成子类的构造函数变成父类的所以子类的构造函数还需还原回来



原创粉丝点击