配列の分割代入
let data = [10, 20, 30, 40, 50];
let [x0, x1, x2, x3, x4] = data
console.log(x0);
console.log(x1);
console.log(x2);
console.log(x3);
console.log(x4);
実行結果
10
20
30
40
50
オブジェクトの分割代入
let car = {manufacturer: "TOYOTA", color: "white", price: 2500000};
let {color, model, price} = car
console.log("color: " + color);
console.log("model: " + model);
console.log("price: " + price);
実行結果
color: white
model: undefined
price: 2500000