1. 程式人生 > >vue知識點總結 --- 擴充套件運算子 … (三個點)

vue知識點總結 --- 擴充套件運算子 … (三個點)

擴充套件運算子 … (三個點)

  • 運算元組
...[1,2,3] => 1,2,3
  • 與解構賦值結合
var [a, ...arr] = [1,2,3,4,5]
a => 1
arr => [2,3,4,5]

var [a, ...arr] = []
a => undefined
arr => []

var [a, ...arr] = ['A']
a => 'A'
arr => []
  • 複製陣列
    1)迴圈
    2)Array.from(arr)
    3)var arr2 = […arr]

  • 字串轉陣列

[...'hello'] => ['h','e','l','l','o']