以下代码的输出结果是:let numbers = [1, 2, 3];let data = {};[data.foo, data.bar] = numbers;console.log(data);
A. 1,2
B. 1,3
C. { foo: 1, bar: 2 }
D. { foo: 1, bar: 3 }
查看答案
在下列代码中,那段代码可以求算出numbers数组的最大值?
A. var numbers = [1, 1, 2, 3, 5, 8];var max = Math.max(numbers);
B. var numbers = [1, 1, 2, 3, 5, 8];var max = Math.max(...numbers);
C. var numbers = [1, 1, 2, 3, 5, 8];var max = Math.max(numbers...);
D. var numbers = [1, 1, 2, 3, 5, 8];var max = Math.max(*numbers);
以下代码的运行结果是什么?function f(...args) {var result = 0;args.forEach(function (value) {result += value;});return result;}f(1, 2, 5);
A. 1
B. 5
C. 8
D. 10
以下代码的输出结果是:function sayHello(greeting = "Hello", name = "CampJS") {console.log(`${greeting} ${name}!`);}sayHello("Hi there");sayHello(undefined, null);
A. Hello CampJS!Hello CampJS!
B. Hi thereCampJS!undefined CampJS!
C. Hi thereCampJS!Hello null!
D. Hi thereCampJS!undefined null!
以下代码的输出结果是:function log(arg, transform = x => x) {console.log(transform(arg));}log("Hello");log("Hello", y => y.toUpperCase());
A. HelloHELLO
B. helloHELLO
C. hellohello
D. HELLOHELLO