Created
July 1, 2019 15:51
-
-
Save jyotiarora2610/ca53ec94fd02e3f7128c3bebd02f3461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function throttle(func, wait) { | |
let flag = true; | |
return function() { | |
let context = this; | |
let args = arguments; | |
if (flag) { | |
func.apply(this, args); | |
flag = false; | |
} | |
else { | |
setTimeout(() => { | |
flag = true | |
}, wait); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment