functioncheck() { var val = this.value; if (val.length < 6) { console.log('Invalid length'); } else { console.log('success'); } }
functionthrottle(fn, delay){ var t = null, begin = newDate().getTime(); returnfunction(){ var _self = this, args = argumens, cur = newDate().getTime(); clearTimeout(t); if( cur - begin >= delay ){ fn.apply(_self, args); begin = cur; }else{ t = setTimeout( ()=>{ fn.apply(_self, args) },delay) } } }