-1
我正在學習es6箭頭函數,我如何才能通過此測試?在定義時間綁定箭頭函數
describe('arrow functions have lexical `this`, no dynamic `this`',() => {
it('bound at definition time, use `=>` ', function() {
var bound = new LexicallyBound();
var fn =() => getFunction();
assert.strictEqual(fn(), bound);
});
什麼'LexicallyBound'?什麼是'getFunction'? –
'class LexicallyBound { getFunction(){ return()=> { return new LexicalBound(); }} getArgumentsFunction(){ 恢復功能(){返回參數}} }' – Bomber
使用 「編輯」,以改善這個問題,不評論。根據這個定義,當你嘗試在它前面調用'getFunction'而沒有'bound.'時,你應該在你的代碼中得到'ReferenceError'。 –