Created
June 26, 2016 06:11
-
-
Save ottonascarella/c874af2d3419a350772eaf05ec438135 to your computer and use it in GitHub Desktop.
Function debouncing Vanilla JS
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.prototype.debounce = function(delay) { | |
var outter = this, | |
timer; | |
return function() { | |
var inner = this, | |
args = [].slice.apply(arguments); | |
clearTimeout(timer); | |
timer = setTimeout(function() { | |
outter.apply(inner, args); | |
}, delay); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment