Appearance
const numbers = [1, 2, 3, 4, 5]; const [y] = numbers; console.log(y);
A. [[1, 2, 3, 4, 5]] B. [1, 2, 3, 4, 5] C. 1 D. [1]
答案: C
输出是 1。
1
在这段代码中,我们定义了一个名为 numbers 的数组,并使用解构赋值从 numbers 中提取第一个元素。解构赋值 [y] 将数组的第一个元素赋值给变量 y。
numbers
[y]
y
因此,当我们打印 y 时,它的值为 1,表示数组中的第一个元素。