-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'。 –