地味によく使う
var toExecutableOnce = function(f){
var called = false, result = undefined;
return function(){
if(!called){
result = f.apply(this, arguments);
called = true;
}
return result;
};
};
var greeting = toExecutableOnce(function(){
console.log("hello");
return "world";
});
console.log(greeting());// hello world
console.log(greeting());// world