博客
关于我
回想继承、原型与原型链有感
阅读量: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/

你可能感兴趣的文章
PLC接线详解
查看>>
PLC数组的使用(西门子)
查看>>
Quarzt定时调度任务
查看>>
PLC结构体(西门子)
查看>>
PLC编程语言ST文本语法的常用数据类型及变量
查看>>
PLC通讯方式
查看>>
Please install 'webpack-cli' in addition to webpack itself to use the CLI
查看>>
Ploly Dash,更新一个Dash应用程序JJJA上的实时人物
查看>>
Ploly烛台的定制颜色
查看>>
Ploly:如何在Excel中嵌入完全交互的Ploly图形?
查看>>
plotloss记录
查看>>
Plotly (Python) 子图:填充构面和共享图例
查看>>
Plotly 中的行悬停文本
查看>>
Plotly 停用 x 轴排序
查看>>
Plotly 域变量解释(多图)
查看>>
Plotly 绘制表面 3D 未显示
查看>>
Plotly-Dash 存在未知问题并创建“加载依赖项时出错“;通过使用 Python-pandas.date_range
查看>>
Plotly-Dash:如何过滤具有多个数据框列的仪表板?
查看>>
Plotly:如何为 x 轴上的时间序列设置主要刻度线/网格线的值?
查看>>
Plotly:如何从 x 轴删除空日期?
查看>>