JsQuestions-1
Contents
// 输出什么?
const myFunc = ({ x, y, z }) => {
console.log(x, y, z);
};
myFunc(1, 2, 3);
A:
123B:
{1: 1}{2: 2}{3: 3}C:
{ 1: undefined }undefinedundefinedD:
undefinedundefinedundefined
解析:
答案: D
myFunc 期望接收一个包含 x, y 和 z 属性的对象作为它的参数。因为我们仅仅传递三个单独的数字值 (1, 2, 3) 而不是一个含有 x, y 和 z 属性的对象 ({x: 1, y: 2, z: 3}), x, y 和 z 有着各自的默认值 undefined.
-来源:Github - Javascript Questions
