前端学习(2538):slice
生活随笔
收集整理的這篇文章主要介紹了
前端学习(2538):slice
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
slice()?方法返回一個新的數組對象,這一對象是一個由?begin 和 end 決定的原數組的淺拷貝(包括 begin,不包括end)。原始數組不會被改變。
?
const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];
console.log(animals.slice(2));
// expected output: Array ["camel", "duck", "elephant"]
console.log(animals.slice(2, 4));
// expected output: Array ["camel", "duck"]
console.log(animals.slice(1, 5));
// expected output: Array ["bison", "camel", "duck", "elephant"]
?
總結
以上是生活随笔為你收集整理的前端学习(2538):slice的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 常见的windows蓝屏代码查询及处理
- 下一篇: 前端学习(2818):小程序学习之新建页