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

你可能感兴趣的文章
pyechart值域区间
查看>>
pyest+appium实现APP自动化测试,思路全总结在这里
查看>>
Pygame
查看>>
Pygame 围绕轴旋转立方体
查看>>
Pygame 的详细介绍-ChatGPT4o作答
查看>>
Pygame 窗口几秒钟后没有响应
查看>>
Pygame.display.togling_fulcreen()不起作用
查看>>
Pygame中的倒数计时器
查看>>
Pygame介绍以及下载
查看>>
Pygame初始-模仿windows待机画面
查看>>