博客
关于我
回想继承、原型与原型链有感
阅读量: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去掉转义符
查看>>
php去除字符串开头或末尾的字符(例如逗号)
查看>>
php反射api
查看>>
PHP反射ReflectionClass、ReflectionMethod 入门教程
查看>>
PHP反射机制
查看>>
php取当天的最后一秒_Docker快速搭建PHP开发环境详细教程
查看>>
php取绝对值
查看>>
PHP变量内容的获取
查看>>
php各种常用的算法
查看>>
php各种缓存策略对比
查看>>
RabbitMQ高级特性 - 消息分发(限流、负载均衡)
查看>>
php后台“爬虫”模拟登录第三方系统
查看>>
php后台的在控制器中就可以实现阅读数增加
查看>>
php命令行生成项目结构
查看>>
php命名空间
查看>>
PHP命名空间带来的干扰
查看>>
PHP和MySQL Web开发从新手到高手,第1天-搭建PHP开发环境
查看>>
php商店管理系统,基于PHP的商店管理系统.doc
查看>>
PHP四大主流框架的优缺点总结
查看>>
PHP图片处理—PNG透明缩放并生成灰图
查看>>