js真正的原型继承

来源:互联网 发布:如何删除小米云端数据 编辑:程序博客网 时间:2024/06/06 16:25
前几天去面试JS  让我写一个原型继承,我居然写一个伪的,今天写了 发出来原型继承function Person(name) {this.name = name;}function student(name,age) {Person.call(this,name); //Person附加到this中,这样student this里就有了Person的THISthis.age = age;console.log(this);}var stu = new student('zhangliang', 25);

原创粉丝点击