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

你可能感兴趣的文章
poj3307
查看>>
Qt笔记——QString与隐式共享、MVC架构
查看>>
Qt笔记——QSemaphore处理生产者/消费者模式
查看>>
Qt笔记——QMutex&QWaitCondition处理生产者消费者模式
查看>>
Qt笔记——QLable+QPixmap图片缩放踩坑
查看>>
Qt笔记——foreach与forever
查看>>
QT程序怎么挪到Linux下,linux+Qt程序如何打包发布
查看>>
Qt知识:视图框架QGraphicsWidget详解
查看>>
SpringBoot中项目启动及定时任务缓存数据库常用数据至内存变量并转换后高频调用
查看>>
Qt知识: 画刷风格
查看>>
QT的OpenGL渲染窗QOpenGLWidget Class
查看>>
QT的C++程序加载动态链接库DLL(Linux下是so)的方式
查看>>
QT界面操作1:如何跟踪鼠标位置?
查看>>
Qt环境搭建(Visual Studio)
查看>>
QT点击"X"按钮,调用closeEvent()函数来实现调用特定事件(附:粗略介绍QT的信号与槽的使用方法)...
查看>>
QT样式表——url路径
查看>>
QT数据库(三):QSqlQuery使用
查看>>
QT教程5:消息框
查看>>
SpringBoot中集成阿里开源缓存访问框架JetCache实现声明式实例和方法缓存
查看>>
pom.xml中提示web.xml is missing and <failonmissingw>...
查看>>