functionthrottle(fun, delay){let last, deferTimer
returnfunction(args){let that =thislet _args = args
let now =+newDate()if(last && now < last + delay){clearTimeout(deferTimer)
deferTimer =setTimeout(function(){
last = now
fun.apply(that, _args)}, delay)}else{
last = now
fun.apply(that,_args)}}}let throttleAjax =throttle(ajax,1000)let inputc = document.getElementById('throttle')
inputc.addEventListener('keyup',function(e){throttleAjax(e.target.value)})