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

你可能感兴趣的文章
OpenAll:Android打开组件新姿势【仅供用于学习了解ButterKnife框架基本原理】
查看>>
OpenASR 项目使用教程
查看>>
Openbox-桌面图标设置
查看>>
opencart出现no such file or dictionary
查看>>
OpenCV 3.1 imwrite()函数写入异常问题解决方法
查看>>
OpenCV 4.1.0版drawContours
查看>>
Opencv cv2.putText 函数详解
查看>>
opencv glob 内存溢出异常
查看>>
opencv Hog Demo
查看>>
opencv Hog学习总结
查看>>
opencv Mat push_back
查看>>
opencv putText中文乱码
查看>>
OpenCV Python围绕特定点将图像旋转X度
查看>>
opencv resize
查看>>
Opencv Sift和Surf特征实现图像无缝拼接生成全景图像
查看>>
opencv SVM分类Demo
查看>>
OpenCV VideoCapture.get()参数详解
查看>>
opencv videocapture读取视频cap.isOpened 输出总是false
查看>>
opencv waitKey() 函数理解及应用
查看>>
OpenCV 中的图像转换
查看>>