[JavaScript] How to get a sub array from an array with start index and end index?
I want to create a sub array with start and end indexes from another array, how can I do this in Javascript?
1 Answer
3 years ago by Jahaan
slice()
method is used to get a sub array from a given array with start and end indices.
For example, consider the start index: 3 and end index: 6
let numbers = [ 45, 22, 67, 90, 47, 88 , 79];
console.log(numbers.slice(3,6)); // outputs [ 90, 47, 88 ]
3 years ago by Meera