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

你可能感兴趣的文章
PHP高效、轻量级表格数据处理库 OpenSpout
查看>>
R 数据缺失的处理
查看>>
php,nginx重启
查看>>
php:$_ENV 和 getenv区别
查看>>
PHP:cURL error 60: SSL certificate unable to get local issuer certificate
查看>>
PHP:PDOStatement::bindValue参数类型php5和php7问题
查看>>
Q媒体播放器.如何播放具有多个音频的视频?
查看>>
pickle
查看>>
Pickle thread.lock(Pymongo)
查看>>
pickle模块
查看>>
qYKVEtqdDg
查看>>
pid控制
查看>>
PID控制介绍-ChatGPT4o作答
查看>>
PID控制器数字化
查看>>
Qwen-VL项目使用指南
查看>>
PIESDKDoNet二次开发配置注意事项
查看>>
PIGS POJ 1149 网络流
查看>>
PIL Image对图像进行点乘,加上常数(等像素操作)
查看>>
PIL Image转Pytorch Tensor
查看>>
PIL&QOOT;IOERROR:带有大图像的图像文件被截断(&Q)
查看>>