Simulate a debounce function

http://obscurejavascript.tumblr.com/post/115595038489/debounce-in-javascript

var debounce = function(callback, delay) {
    var timeout = null;

    return function() {
        var args = arguments,
            context = this;

        clearTimeout(timeout);
        timeout = setTimeout(function() {
            callback.apply(context, args);
        }, delay);
    };
};
This entry was posted in Javascript. Bookmark the permalink.