str.replace(/\s/g,"") 去所有空格
function debounce(fn, wait) {//函数 时间
var timeout = null;
return function() {
if(timeout !== null) clearTimeout(timeout);
timeout = setTimeout(fn, wait);
}
}
function throttle(func, delay) {//执行体 延迟时间
var prev = Date.now();
return function() {
var context = this;
var args = arguments;
var now = Date.now();
if (now - prev >= delay) {
func.apply(context, args);
prev = Date.now();
}
}
}
module.exports = {
debounce,
throttle
}