A couple years ago the notion of managing JS execution with timers was in vogue – IDK what caused that particular wave of interest, but I remember doing the same thing to mousemoves around 2001/2002 (when it really mattered – you could actually watch the caret blink less frantically as your throttling function upped it’s threshold). Anyways, for reference, here’s my take:

(caveat: this is especially un-proven in the field, even for this site… at least a couple of the non-polluting versions have been tested (a little), but the protos haven’t been run at all – they should work in theory but I haven’t had the time to check… LMK if not)

Function.prototype.debounce = function(threshold){
	var callback = this;
	var timeout;
	return function() {
		var context = this, params = arguments;
		window.clearTimeout(timeout);
		timeout = window.setTimeout(function() {
			callback.apply(context, params);
		}, threshold);
	};
};
Function.prototype.throttle = function(threshold){
	var callback = this;
	var suppress = false;
	var clear = function() {
		suppress = false;
	};
	return function() {
		if (!suppress) {
			callback.apply(this, arguments);
			window.setTimeout(clear, threshold);
			suppress = true;
		};
	}
};

Non-polluting…

var FunctionUtilities = {
	debounce: function(callback, threshold) {
		var timeout;
		return function() {
			var context = this, params = arguments;
			window.clearTimeout(timeout);
			timeout = window.setTimeout(function() {
				callback.apply(context, params);
			}, threshold);
		};
	},
	throttle: function(callback, threshold){
		var suppress = false;
		var clear = function() {
			suppress = false;
		};
		return function() {
			if (!suppress) {
				callback.apply(this, arguments);
				window.setTimeout(clear, threshold);
				suppress = true;
			};
		}
	}
};