博客
关于我
回想继承、原型与原型链有感
阅读量:450 次
发布时间:2019-03-06

本文共 909 字,大约阅读时间需要 3 分钟。

function People(name, age) {    this.name = name;    this.age = age;    this.eat = function () {        console.log(`${this.name}: people eat!`);    };}People.prototype.protoEat = function () {    console.log(`${this.name}: proto eat!!`);}; function Student(name, age) {People.call(this, name, age);Student.prototype.constructor = Student;} Student.prototype = new People();
function People(name, age) {this.name = name;this.age = age;this.eat = function () {console.log(${this.name}: eat!);};}People.prototype.protoEat = function () {console.log(${this.name}: proto eat!!);}; function Student(name, age) {People.call(this, name, age);} for (const key in People.prototype) {Student.prototype[key] = People.prototype[key];}
var obj = {name: "People",eat: function () {console.log("eat fn!");}}; function clone(obj) {const Fn = new Function();Fn.prototype = obj;return new Fn();} const tt = clone(obj);tt.eat();

转载地址:http://isufz.baihongyu.com/

你可能感兴趣的文章
PKUSC2018游记
查看>>
PK项目测试,做产品测试有这4大优势!
查看>>
pl sql 的目录 所在的目录 不能有 小括号,如 Program Files (x86)
查看>>
PL SQLDEVELOPMENT导出数据库脚本
查看>>
Queue
查看>>
PL/SQL Developer中文版下载以及使用图解(绿色版)
查看>>
pl/sql developer乱码,日期格式等问题解决
查看>>
PL/SQL 中的if elsif 练习
查看>>
PL/SQL 存储函数和过程
查看>>
query简单入门到精通细节 - (六)Jquery效果之“淡入与淡出”
查看>>
PL/SQL提示“ORA-01722:无效数字,将无效数字查找出来
查看>>
PL/sql语法单元
查看>>
PL/SQL连接远程服务器数据库,出现ORA-12154: TNS: 无法解析指定的连接标识符。
查看>>
pl/sql锁
查看>>
PL2303 Windows 10 驱动项目常见问题解决方案
查看>>
QueryPerformanceCounter与QueryPerformanceFrequency
查看>>
Plaid.com的监控系统如何实现与9600多家金融机构的集成
查看>>
Plain Stock Prediction:基于RNN的股票价格预测工具
查看>>
platform_driver与file_operations两种方法开发led驱动
查看>>
PlatON共识方案详解:应用CBFT共识协议,提高共识效率
查看>>