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

你可能感兴趣的文章
org/eclipse/jetty/server/Connector : Unsupported major.minor version 52.0
查看>>
org/hibernate/validator/internal/engine
查看>>
orm总结
查看>>
os.system 在 Python 中不起作用
查看>>
SQL--合计函数(Aggregate functions):avg,count,first,last,max,min,sum
查看>>
OSError: no library called “cairo-2“ was foundno library called “cairo“ was foundno library called
查看>>
OSG学习:几何对象的绘制(三)——几何元素的存储和几何体的绘制方法
查看>>
OSG学习:场景图形管理(三)——多视图相机渲染
查看>>
OSG学习:场景图形管理(四)——多视图多窗口渲染
查看>>
Sql 随机更新一条数据返回更新数据的ID编号
查看>>
OSG学习:空间变换节点和开关节点示例
查看>>
OSG学习:纹理映射(一)——多重纹理映射
查看>>
OSG学习:纹理映射(二)——一维/二维/简单立方图纹理映射
查看>>
OSG学习:纹理映射(六)——灯光
查看>>
OSPF 四种设备角色:IR、ABR、BR、ASBR
查看>>
OSPF不能发现其他区域路由时,该怎么办?
查看>>
SQL Server 存储过程
查看>>
OSPF在大型网络中的应用:高效路由与可扩展性
查看>>
OSPF技术连载18:OSPF网络类型:非广播、广播、点对多点、点对多点非广播、点对点
查看>>
OSPF技术连载21:OSPF虚链路,现代网络逻辑连接的利器!
查看>>