JamieMason/memoize.js — pull request #1 by AutoSponge (2011-10-24 23:14:31+00:00)
Title: Micro-optimization, JSON support safe

I modified your code to cache a reference to the JSON.stringify method in the closure. It's also more obvious that this will be GLOBAL unless the first parameter is modified. If a browser doesn't have JSON.stringify, one could change the second paramter--either way, if the second parameter is falsey, the fallback function just returns the supplied function (no memoizing). Lastly, I don't think the call to slice is needed, it seems to cache just fine in FF, IE, and Chrome without it.

There does seem to be some performance gain based on js perf tests.

Thanks for the examples,
Paul