來源:互聯網網民 2008-09-09 07:29:10
評論最近看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]