web-interview icon indicating copy to clipboard operation
web-interview copied to clipboard

[选择题] 57.(单选题)下面代码的输出是什么

Open qiilee opened this issue 5 years ago • 0 comments

const myFunc = ({ x, y, z }) => {
  console.log(x, y, z);
};

myFunc(1, 2, 3);
A:1 2 3
B: {1: 1} {2:2} {3:3}
C: {1: undefined} undefined undefined
D: undefined undefined undefined

答案:D

解析:

myFunc 期望接收一个包含 x,y 和 z 属性的对象作为它的参数,因为我们仅仅传递三个单独的数字值(1,2,3)不是一个含有 x,y 和 z 属性的对象({x:1,y:2,z:3}),x,y 和 z 有着各自的默认值 undefined

qiilee avatar Apr 15 '20 11:04 qiilee