0
是否有隻會執行一次的函數的官方術語或單詞?我能想到的最簡單的例子就是這樣的閉包中的javascript函數。 (從here截取)只能執行一次的函數的分類
function createChance() {
var chanceLeft = true;
return function() {
if (chanceLeft) {
console.log("This was the only chance you had.");
chanceLeft = false;
} else {
console.log('Sorry: you already used your chance');
}
};
}
var chance = createChance();
chance();
// This was the only chance you had.
chance();
// Sorry: you already used your chance
我並不知道ide ence的「超出最初應用」部分。謝謝。 –