js防抖函数中的this和参数问题
这个问题是我在昨天的面试中被问到的问题,之前没有研究过,当时脑子一片混乱没有答出来,当时让我写防抖函数,我是这样写的:function debounce (fn, delay) { let temp = null; return function () { if(temp) clearTimeout(temp); temp = setTimeout(() => { fn(); }, delay); }}然后就被问到fn的this和参数怎么办,首先来解决一下this的问题
原创
2020-08-08 17:26:28 ·
2592 阅读 ·
7 评论