Open jawayang opened 8 years ago
題目:
You'll implement once, a function that takes another function as an argument, and returns a new version of that function that can only be called once.
Subsequent calls to the resulting function should have no effect (and should return undefined).
For example:
function foo() { console.log('foo'); } fooOnce = once(foo) fooOnce() // -> "foo" fooOnce() // -> no effect
http://www.codewars.com/kata/5307ff5b588fe6d7000000a5/train/javascript
翻譯: 實現一個函數 once,它接受另一個函數作為參數,並返回該函數只能被調用一次的新版本。 所得到的函數的後續調用應該沒有任何效果(而且應該返回undefined) For example:
function foo() { console.log('foo'); } fooOnce = once(foo) // 把foo傳入once得到新函數fooOnce fooOnce() // -> "foo" (第一次調用fooOnce) fooOnce() // -> no effect (第二次以後調用fooOnce 沒有任何效果)
by Larry Huang
PASS
pass
題目:
You'll implement once, a function that takes another function as an argument, and returns a new version of that function that can only be called once.
Subsequent calls to the resulting function should have no effect (and should return undefined).
For example:
http://www.codewars.com/kata/5307ff5b588fe6d7000000a5/train/javascript
翻譯: 實現一個函數 once,它接受另一個函數作為參數,並返回該函數只能被調用一次的新版本。 所得到的函數的後續調用應該沒有任何效果(而且應該返回undefined) For example:
by Larry Huang