![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js
文章平均质量分 66
金汛
试一试
展开
-
js prototype.constructor指正
直接上代码Parent.prototype.getName = function () {console.log(this.name)}function Child (name, age) {Parent.call(this, name);this.age = age;}Child.prototype = new Parent();Child.prototype.constructor = Child;var child1 = new Child(‘kevin’, ‘18’);chi原创 2021-05-31 22:52:24 · 240 阅读 · 0 评论 -
js call的实现卡住我的点
在刚开始了解如何实现call的时候,context.fn = this;context.fn(); 这两句话把我卡了很久Function.prototype.call2 = function(context) {// 首先要获取调用call的函数,用this可以获取context.fn = this;context.fn();delete context.fn;}// 测试一下var foo = {value: 1};function bar() {console.log(t.原创 2021-05-31 20:29:47 · 176 阅读 · 0 评论