2021年6月11日
摘要: //节流 let jFn = (function(){ let isDo = false; return function(fn,time){ if(isDo) return; isDo = true; setTimeout(function(){ fn(); isDo = false; },tim 阅读全文
posted @ 2021-06-11 12:29 皮杰克 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 1.this对象指向定义时所在对象。call、apply、bind等不会改变this 2.不能作为构造函数 new 会报错 3.没有arguments 4.没有原型对象 5.不能用作generator函数 阅读全文
posted @ 2021-06-11 11:43 皮杰克 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 1.new 一个函数时,函数内的this指向一个新的对象.(权重1) 2.事件里面的this指向调用事件的元素(权重3) 3.apply、call或bind调用或创建的函数,函数内的this指向方法绑定的对象(权重2) 4.不符合上述规则this指向全局上下文(权重4) 5.箭头函数this指向该函 阅读全文
posted @ 2021-06-11 11:36 皮杰克 阅读(46) 评论(0) 推荐(0) 编辑
摘要: let obj = { a:1, b:2 } Function.prototype.myApply = function(content,arr){ console.log('myApply'); let _this = this; let sy = Symbol(); content[sy] = 阅读全文
posted @ 2021-06-11 11:00 皮杰克 阅读(39) 评论(0) 推荐(0) 编辑
摘要: let obj = { a:1, b:2 } Function.prototype.myCall = function(content,...arg){ let _this = this let sy = Symbol(); content[sy] = _this; return content[s 阅读全文
posted @ 2021-06-11 10:55 皮杰克 阅读(27) 评论(0) 推荐(0) 编辑
摘要: Function.prototype.myBind = function(content,...arg){ let _this = this; return function(...arguments){ _this.call(content,...arg.concat(arguments)); } 阅读全文
posted @ 2021-06-11 10:33 皮杰克 阅读(36) 评论(0) 推荐(0) 编辑