example:
function delay(fn, ms) {
let timer = 0;
return function(...args) {
clearTimeout(timer);
timer = setTimeout(fn.bind(this, ...args), ms || 0);
}
}
$('input[name="example"]').keyup(delay(function (e) {
// to do something ....
console.log('Time elapsed!', this.value);
}, 500));