What is happening when you're destructing an array without using square brackets?

mem*_*d23 0 javascript

Python developer here. I am using JavaScript to run the following command,

let a = [1, 2, 3];
let b , c, d = a;
console.log(b);
console.log(c);
console.log(d);
Run Code Online (Sandbox Code Playgroud)

To my surprise, b and c are undefined while d is the entire a variable. I later realize that I am meant to go let [b, c, d] = a;, however I am just trying to understand what is happening and why they're undefined.

kni*_*ttl 5

不是在解构。

let b , c, d = a;
Run Code Online (Sandbox Code Playgroud)

声明 3 个变量并为其中之一赋值。上面的行与以下内容相同:

let b;
let c;
let d = a;
Run Code Online (Sandbox Code Playgroud)

此语法允许您在单个语句中声明(并可选择分配)多个变量,例如

let tmp, x = 4, i, y = 2, z = x * 10 + y;
Run Code Online (Sandbox Code Playgroud)

未分配的变量默认初始化为undefined

参考: