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

你可能感兴趣的文章
PostgreSQL学习总结(10)—— PostgreSQL 数据库体系架构
查看>>
PostgreSQL学习总结(11)—— PostgreSQL 常用的高可用集群方案
查看>>
Qt开发——多线程网络时间客户端
查看>>
PostgreSQL学习总结(13)—— PostgreSQL 15.8 如何成就数据库性能王者?
查看>>
PostgreSQL学习总结(13)—— PostgreSQL 目录结构与配置文件 postgresql.conf 详解
查看>>
PostgreSQL学习总结(1)—— PostgreSQL 入门简介与安装
查看>>
PostgreSQL学习总结(2)—— PostgreSQL 语法
查看>>
PostgreSQL学习总结(3)—— PostgreSQL 数据类型
查看>>
Qt开发——圆面积计算器
查看>>
PostgreSQL学习总结(5)—— PostgreSQL table 创建与删除
查看>>
PostgreSQL学习总结(6)—— PostgreSQL 模式(SCHEMA)详解
查看>>
PostgreSQL学习总结(7)—— PostgreSQL 语句 INSERT INTO、SELECT、UPDATE、DELETE 等学习
查看>>
PostgreSQL学习总结(8)—— PostgreSQL 基于数据库和基于模式(schema)的多租户分析
查看>>
PostgreSQL学习总结(9)—— PostgreSQL 运算符与表达式
查看>>
PostGreSql学习笔记001---PostgreSQL10.4安装(Windows)_支持PostGreGis_PostJDBC
查看>>
PostGreSql学习笔记002---Navicat Premium中管理PostGreSql 错误:字段rolcatupdate 不存在
查看>>
PostgreSQL学习笔记:PostgreSQL vs MySQL
查看>>
PostgreSQL实现shape数据转geojson数据(地图工具篇.18)
查看>>
PostgreSQL导入shape数据(地图工具篇.10)
查看>>
PostGreSql工作笔记003---在Navicat中创建数据库时报错rolcatupdate不存在_具体原因看其他博文_这里使用pgAdmin4创建管理postgre
查看>>