单行Javascript实现Memoization
最近看fp比较上瘾。。。JS里的各种奇淫巧计也是不亦乐乎。oliver用单行javascript实现了fp里的memoizaion
Bezier.prototype.getLength = function() {
var length = ... // 复杂、expensive的计算
return (this.getLength = function(){return length})();
}
原文讲得比较详细,内存泄漏都考虑到了。地址是 http://osteele.com/archives/2006/04/javascript-memoization
特别声明:以上内容(如有图片或视频亦包括在内)为网络用户发布,本站仅提供信息存储服务。
最近看fp比较上瘾。。。JS里的各种奇淫巧计也是不亦乐乎。oliver用单行javascript实现了fp里的memoizaion
Bezier.prototype.getLength = function() {
var length = ... // 复杂、expensive的计算
return (this.getLength = function(){return length})();
}
原文讲得比较详细,内存泄漏都考虑到了。地址是 [url=http://osteele.com/archives/2006/04/javascript-memoization]http://osteele.com/archives/2006/04/javascript-memoization[/url]