2021年6月21日
摘要: let arr = [1,2,3]; arr .reduce((promise,current)=>{ return promise.then(()=>{ return new Promise(resolve=>{ setTimeout(()=>{ console.log(current); res 阅读全文
posted @ 2021-06-21 16:40 皮杰克 阅读(222) 评论(0) 推荐(0) 编辑
  2021年6月19日
摘要: function timeout(delay=1000){ return new Promise((resolve,reject)=>{ setTimeout(resolve,delay); }) } timeout().then(()=>{ console.log(1); return timeo 阅读全文
posted @ 2021-06-19 17:01 皮杰克 阅读(515) 评论(0) 推荐(0) 编辑
摘要: let p1 = new Promise((resolve,reject)=>{ //resolve('resolve') reject('reject') }); p1.then(a=>{ console.log(a); },b=>{ console.log(b); return 1; }).th 阅读全文
posted @ 2021-06-19 14:03 皮杰克 阅读(30) 评论(0) 推荐(0) 编辑
  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) 编辑
  2021年5月31日
摘要: 一.定义: 1.浅拷贝 创建一个新对象,这个对象有着原始对象属性值的一份精确拷贝。如果属性是基本类型,拷贝的就是基本类型的值,如果属性是引用类型,拷贝的就是内存地址 ,所以如果其中一个对象改变了这个地址,就会影响到另一个对象。 2.深拷贝 将一个对象从内存中完整的拷贝一份出来,从堆内存中开辟一个新的 阅读全文
posted @ 2021-05-31 15:38 皮杰克 阅读(86) 评论(0) 推荐(0) 编辑