Reputation: 2215
I learn this Array prototype slice
This is what I tried:
const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];
console.log(animals.slice(1, 2));
//outputs: ["bison"]
Why is this not outputting ["bison", "camel"] since the doc state it's a zero because operation?
Upvotes: 0
Views: 43
Reputation: 1669
the end is not included more info
The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.
Upvotes: 1