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

你可能感兴趣的文章
Python requirements.txt的使用方法
查看>>
Python REST(Web 服务)框架的推荐?
查看>>
Python rsa 加密
查看>>
Python RSA操作
查看>>
Python轻松实现统计学中重要的相关性分析
查看>>
Python scrapy 常见问题及解决 【遇到的坑】
查看>>
Python Seborn热图数据的动态更新
查看>>
Python Seborn绘制空白直方图
查看>>
Python Selenium - 获取href值
查看>>
Python Selenium实现自动化测试及Chrome驱动使用!
查看>>
Python Selenium搭建UI自动化测试框架
查看>>
Python Selenium模块详解
查看>>
Python selenium爬取影评生成词云图
查看>>
python selenium自动化测试报告
查看>>
Python selenium自动化测试框架实战 —— 登录测试案例
查看>>
Python Selenium设计模式 —— POM
查看>>
Python Serial:如何使用 read 或 readline 函数一次读取多个字符
查看>>
Python set([]) 如何检查两个对象是否相等?一个对象需要定义哪些方法来自定义它?
查看>>
Python setup.py:数据文件无法复制目录:不存在或不是常规文件
查看>>
Python setuptools sdist:仅安装版本化文件
查看>>