2021年1月11日

怎么优雅的获取数组最后一项.

摘要: const arr = [1,2,3,4,5] 1:const [lastItem] = arr.slice(-1) console.log(lastItem) 2:const len = arr.length console.log(arr[len-1]) 3: const lastItem = 阅读全文

posted @ 2021-01-11 09:27 冰love 阅读(755) 评论(0) 推荐(0) 编辑

导航