多项选择题
关于箭头函数错误的是()
A.const cat = {lives: 9,jumps: () => { this.lives--; }} ;
B.var button = document.getElementById('press');button.addEventListener('click', () => {this.classList.toggle('on');}); ;
C.let insert = (value) => ({into: (array) => ({after: (afterValue) => { array.splice(array.indexOf(afterValue) + 1, 0, value);return array;}})});
D.const mult2 = a => a * 2;
相关考题
-
多项选择题
function foo(){return()=>{return()=>{return()=>{console.log(’id:’,this.id);};};};}var f=foo.call({id:1});根据上面的代码,下面选项正确的是()
A.var t1 = f.call({id: 2})()(); // id: 2
B.var t2 = f().call({id: 3})(); // id:1
C.var t3 = f()().call({id: 4}); // id: 4
D.var t1 = f.call({id: 2})()(); // id: 1 -
多项选择题
箭头函数有几个使用注意点,正确的是()
A.函数体内的this对象,就是定义时所在的对象,而不是使用时所在的对象
B.不可以当作构造函数,也就是说,不可以使用new命令,否则会抛出一个错误
C.不可以使用arguments对象,该对象在函数体内不存在。如果要用,可以用rest参数代替
D.不可以使用yield命令,因此箭头函数不能用作Generator函数 -
单项选择题
箭头函数的错误写法是哪个?()
A.[1,2,3].map(x * x);
B.var result = values.sort((a, b) => a - b);
C.const numbers = (...nums) => nums;
D.let insert = (value) => ({into: (array) => ({after: (afterValue) =>{array.splice(array.indexOf(afterValue) + 1, 0, value);return array;}})});