newArray = currentArray.concat(value1, value2, ...)
newArray | 合併後的新陣列 |
currentArray | 目前陣列 |
value | 可以是單一值或是一個陣列 |
let currentArray = [1, 2, 3, 4, 5]
let newArray = currentArray.concat(99)
console.log(newArray)
// (6) [1, 2, 3, 4, 5, 99]
let currentArray = [1, 2, 3, 4, 5]
let someArray = ['Hi', 'David', 888]
let newArray = currentArray.concat(someArray)
console.log(newArray)
// (8) [1, 2, 3, 4, 5, "Hi", "David", 888]