0

How to return a portion of an existing array in JavaScript

JavaScript
let fruits = ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango']
let citrus = fruits.slice(1, 3)

console.log(fruits); // fruits contains ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango']
console.log(citrus); // citrus contains ['Orange','Lemon']
RUN
add comment
Suggest a different solution or add another example