function debounce(fn, delay) {
var timer = null;
return function () {
var context = this;
if(timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
fn.call(context, ...arguments);
}, delay || 500);
}
}
window.onresize = debounce(function() {
console.log('window onresize end');
}, 500)