📘arr.slice()

// 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?