simple-utils-js
Version:
前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown
21 lines (19 loc) • 395 B
JavaScript
/**
* @description: 节流
* @param {*}
* @return {*}
*/
const throttle = (function() {
let timeout = null;
return function(func, wait) {
let context = this;
let args = arguments;
if (!timeout) {
timeout = setTimeout(() => {
timeout = null;
func.apply(context, args)
}, wait)
}
}
})();
module.exports = throttle