Javascript Lazy Function Definition
This is an oldy-but-goody.
If you have an expensive function in javascript that will always return the same results... make it do its dirty-work only once:
JavaScript:
-
var foo = function() {
-
var t = new Date();
-
foo = function() {
-
return t;
-
};
-
return foo();
-
};
