I just thought about this:
function memoize(fn) {
var cache = {};
return function() {
var args = Array.prototype.slice.call(arguments).toString();
if (!cache[args]) {
cache[args] = fn.call(this, arguments);
}
return cache[args];
}
}
It's very cross-browser. I can't think of any browser not supporting this.
But it does feel kind of ugly. It's still the best I can think of though.