日期: 2022 年 8 月 15 日

4 篇文章

【JavaScript】手写AJAX
//什么是Ajax? async JavaScript and XML(JSON) let xhr = new XMLHttpRequest(); xhr.open('GET','/requestHttpDemo'); // xhr.onload = () => { // console.log(�…
【JavaScript】手写防抖
// 概念:回城被打断 let debounce = (fn, time, asThis) => { let timer = null; return (...args) => { if (timer) { clearTimeout(timer) } timer = setTimeout(() => { fn.call(asThi…
【JavaScript】手写节流
// 概念:触发CD let debounce = (fn, time, asThis) => { let cooldown = false; let timer = null; return (...args) => { if (cooldown) { return; } fn.call(asThis, ...args) cooldo…