When I run this code, I don't see any console log in the console. Is the debounce method (taken from here) not executing the method at all?
function debounce(func, wait, immediate) {
var timeout;
var args = Array.prototype.slice.call(arguments, 3);
return function () {
var context = this;
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(function () {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
}, wait);
if (callNow) func.apply(context, args);
};
};
var f1 = function(){ console.log(1) };
var f2 = function(){ console.log(2) };
debounce( f1, 100, false );
debounce( f2, 100, false );
Is this the expected behavior or did I missed something here?