单行Javascript实现Memoization
来源:岁月联盟
时间:2008-09-09
Bezier.prototype.getLength = function() {
var length = ... // 复杂、expensive的计算
return (this.getLength = function(){return length})();
}
原文讲得比较详细,内存泄漏都考虑到了。地址是 http://osteele.com/archives/2006/04/javascript-memoization