随笔分类 - js
摘要:函数防抖debounce:(多次操作合并为一次) 1 function debounce (fn,delay) { 2 var timer = null; 3 return function (e) { 4 clearTimeout(timer); 5 timer = setTimeout(() =
阅读全文
摘要:宏任务:setTimeout,setInterval,DOM事件,AJAX请求 微任务:Promise,asyc/await 1 //主线程直接执行 2 console.log('1'); 3 //丢到宏事件队列中 4 setTimeout(function() { 5 console.log('2
阅读全文
摘要:1.push(),向数组末尾添加一个或多个元素。 2.pop(),删除并返回数组最后一个元素,若数组为空,则返回undefined。 3.shift(),删除并返回数组开头第一个元素,若数组为空,则返回undefined。 4.unshift(),向数组开头添加一个或多个元素。 5.arr1.con
阅读全文