let [foo, [[bar], baz]] = [1, [[2], 3]];
foo // 1
bar // 2
baz // 3

let [ , , third] = ["foo", "bar", "baz"];
third // "baz"

let [x, , y] = [1, 2, 3];
x // 1
y // 3

let [head, ...tail] = [1, 2, 3, 4];
head // 1
tail // [2, 3, 4]

let [x, y, ...z] = ['a'];
x // "a"
y // undefined
z // []

 

相关文章:

  • 2021-09-11
  • 2022-12-23
  • 2021-10-23
  • 2021-10-26
  • 2021-06-14
  • 2022-02-28
  • 2022-12-23
猜你喜欢
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案