06 2021 档案
promise加载队列实现
摘要:let arr = [1,2,3]; arr .reduce((promise,current)=>{ return promise.then(()=>{ return new Promise(resolve=>{ setTimeout(()=>{ console.log(current); res
阅读全文
promise 封装定时器
摘要:function timeout(delay=1000){ return new Promise((resolve,reject)=>{ setTimeout(resolve,delay); }) } timeout().then(()=>{ console.log(1); return timeo
阅读全文
关于promise
摘要:let p1 = new Promise((resolve,reject)=>{ //resolve('resolve') reject('reject') }); p1.then(a=>{ console.log(a); },b=>{ console.log(b); return 1; }).th
阅读全文
节流防抖
摘要://节流 let jFn = (function(){ let isDo = false; return function(fn,time){ if(isDo) return; isDo = true; setTimeout(function(){ fn(); isDo = false; },tim
阅读全文
箭头函数特点
摘要:1.this对象指向定义时所在对象。call、apply、bind等不会改变this 2.不能作为构造函数 new 会报错 3.没有arguments 4.没有原型对象 5.不能用作generator函数
阅读全文
this
摘要:1.new 一个函数时,函数内的this指向一个新的对象.(权重1) 2.事件里面的this指向调用事件的元素(权重3) 3.apply、call或bind调用或创建的函数,函数内的this指向方法绑定的对象(权重2) 4.不符合上述规则this指向全局上下文(权重4) 5.箭头函数this指向该函
阅读全文
手写apply
摘要:let obj = { a:1, b:2 } Function.prototype.myApply = function(content,arr){ console.log('myApply'); let _this = this; let sy = Symbol(); content[sy] =
阅读全文
手写call
摘要:let obj = { a:1, b:2 } Function.prototype.myCall = function(content,...arg){ let _this = this let sy = Symbol(); content[sy] = _this; return content[s
阅读全文
手写bind函数
摘要:Function.prototype.myBind = function(content,...arg){ let _this = this; return function(...arguments){ _this.call(content,...arg.concat(arguments)); }
阅读全文
浙公网安备 33010602011771号