Knowledgize

.slice()

Returns a shallow copy of a portion of an array into a new array object.


Examples:

let fruits = ['apple', 'banana', 'orange', 'mango']; let citrus = fruits.slice(2, 3); console.log(citrus); // ['orange']
let firstTwo = fruits.slice(0, 2); console.log(firstTwo); // ['apple', 'banana']