1// array.slice(start, end)
2const FRUITS = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
3var citrus = FRUITS.slice(1, 3);
4// citrus => [ 'Orange', 'Lemon' ]
5
6// Negative values slice in the opposite direction
7var fromTheEnd = FRUITS.slice(-3, -1);
8// fromTheEnd => [ 'Lemon', 'Apple' ]
1var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
2var citrus = fruits.slice(1, 3);
3// ["Orange", "Lemon"]
1let subArray = array.slice(startIndex, endIndex)
2// ['a', 'b', 'c'].slice(0, 2) === ['a', 'b']
1const ar = [1, 2, 3, 4, 5];
2
3// slice from 1..3 - add 1 as the end index is not included
4
5const ar2 = ar.slice(1, 3 + 1);
6
7console.log(ar2);