console
var i = document.querySelector('input')
function debounce(fn,delay) {
let timer = null
return function() {
clearTimeout(timer)
timer = setTimeout(fn.bind(this),delay)
}
}
function throttle(fn,delay) {
let timer = null
return function() {
if (timer) return
timer = setTimeout(()=>{
timer = null
fn.bind(this)(arguments)
}, delay)
}
}
function func() {
var p = document.createElement('p')
p.innerText = this
document.body.appendChild(p)
}
i.oninput = throttle(func,1000)
<input type="text">
<input type="text">