Lazy Function Definition Pattern
Lazy Function Definition Pattern
Sometimes there’s setup involved with a function that we would prefer to only have to execute if the function is needed. It’s also preferable to not have to do an if statement every function call, since less logic is more efficient.
var foo = function() {
var t = new Date();
foo = function() {
return t;
};
return foo();
};