-1
私はこのテストに合格するためにどのようにes6 arrow関数を学習していますか?定義時に矢印機能がバインドされています
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 LexicallyBound(); }} getArgumentsFunction(){ return関数(){引数を返す}} } ' – Bomber
使用 "編集"、コメント、質問をしませ改善します。そして、その定義に基づいて、あなたは 'getFunction'をその前に' bound.'を付けずに呼び出そうとすると、あなたのコードで 'ReferenceError'を得ているはずです。 –