๐arr.slice()
arr.slice() returns a new array.
// slice 0 1 2 3 4
const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];
// โญ๏ธ new array โฐโslice(2, 4)โโฏ
// 2 <= index < 4
animals.slice(2,4) // ['camel', 'duck']
Last updated
Was this helpful?