1 // 刪除數組中某一項,傳入數組和要刪除的項 2 const delArrItem = (arr, item) => { 3 let index = arr.indexOf(item) 4 5 // 短路表達式,前面的為true才會執行后面的 6 index != -1 && arr.splice(index, 1) 7 }
1 // 刪除數組中某一項,傳入數組和要刪除的項 2 const delArrItem = (arr, item) => { 3 let index = arr.indexOf(item) 4 5 // 短路表達式,前面的為true才會執行后面的 6 index != -1 && arr.splice(index, 1) 7 }
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。