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

你可能感兴趣的文章
OpenStack 搭建私有云主机实战(附OpenStack实验环境)
查看>>
OpenStack 综合服务详解
查看>>
OpenStack 网络服务Neutron技术内幕
查看>>
OpenStack 网络服务Neutron详解
查看>>
Openstack 网络管理企业级实战
查看>>
OpenStack 计算服务Nova详解
查看>>
Openstack(两控制节点+四计算节点)-1
查看>>
openstack--memecache
查看>>
openstack-keystone安装权限报错问题
查看>>
openstack【Kilo】汇总:包括20英文文档、各个组件新增功能及Kilo版部署
查看>>
openstack下service和endpoint
查看>>
【Docker知识】重定向 Docker 的根目录
查看>>
Openstack企业级云计算实战第二、三期培训即将开始
查看>>
OpenStack创建虚拟机实例实战
查看>>
OpenStack安装部署实战
查看>>
OpenStack实践系列⑨云硬盘服务Cinder
查看>>
OpenStack架构
查看>>
OpenStack版本升级与故障排查实战
查看>>
Openstack的HA解决方案【替换原有的dashboard】
查看>>
OpenStack的基本概念与架构详解
查看>>