const arr = [1, 2, 2, 3]
const newArr = Array.from(new Set(arr))
console.log(newArr) // [1, 2, 3]
// join() 陣列轉換成字串
const strArr = ['A', 'B', 'C']
let defaultStr = strArr.join()
let spaceStr = strArr.join('')
let str = strArr.join('、')
console.log(defaultStr) // A,B,C
console.log(spaceStr) // A B C
console.log(str) // A、B、C
// split() 字串轉陣列
const str = '1 2 3 4 5 6'
// ["1", "2", "3", "4", "5", "6"]
console.log(str.split(' '))
// Array.from() 字串轉陣列
cosnt str = 'foo'
console.log(Array.from(str)) // ["f", "o", "o"]
const str = 'Mom Get The Camera'
const result = str.split('').reverse().join('')
console.log(result)
丟個連結 此文寫的太好惹 推薦
const numArr = [1, 2, 3, 4, 5]
console.log('最大值', Math.max(...numArr))
console.log('最小值', Math.min(...numArr))
// length
let arr = [1, 2, 3]
arr.length = 2
console.log(arr) // [1, 2]
arr.length = 0
console.log(arr) // []
const emptyArr = []
console.log(emptyArr.length === 0) //true
const arrPlus = [1, 2, 3]
arrPlus.length = 5
// [1, 2, 3, undefined, undefined]
// GoogleChrome 顯示 empty !?
console.log(arrPlus)
MDN
andyyou
Summer。桑莫。夏天
StackOverFlow產數字陣列