--- tags: Array, Javascript disqus: hackmd --- # [JS]Array 陣列大補帖 [JavaScript之一定要了解的 Array 與方法 系列](https://ithelp.ithome.com.tw/users/20104175/ironman/2584) [JavaScript Array 陣列操作方法大全 ( 含 ES6 )](https://www.oxxostudio.tw/articles/201908/js-array.html#array_reduce) [9種必須知道的陣列方法](https://medium.com/javascript-in-plain-english/9-must-know-javascript-array-methods-6205d3113283) --- [Array.from](https://hackmd.io/YdKJxuOuT728_JI2qST-Eg?view) [Array.prototype.find()](https://hackmd.io/Nieu8TFxR6iPdCxeLZyf8w?view) [Array.prototype.map()](https://hackmd.io/sf5ZTghKSzmMp0jXtyenDg?view) [Array.prototype.forEach()](https://hackmd.io/bFn9eWtNRT6A2kGnWmdlOA?view) [Array.prototype.includes()](https://hackmd.io/ftlMW6QBRCG_QpyUar57Pw?view) --- ### push 從屁股塞一個進去 ### pop 從屁股拿一個出去 ### shift 從頭拿一個出去 ### unshift 從頭塞一個進去 ### splice 從指定index拿出指定數量 ```javascript= const test = ['a', 'b', 'c', 'd'] test.splice(2, 1) //test = ['a', 'b', 'd'] test.splice(0, 2) //test = ['c', 'd'] test.splice(1) //test = ['a', 'b'] test.splice(2, 1, 'F') //test = ['a', 'b', 'F', 'd'] var AA = test.splice(0, 2) AA //AA = ['a', 'b'] test //test = ['c', 'd'] ``` ### slice ### sort 依照陣列元素做排序 ### reverse 依照陣列元素做反向排序 ### filter ### map