[πŸ˜ƒ, πŸ€, πŸ…, 🐡].slice(0, 2); πŸ‘‰ [πŸ˜ƒ, πŸ€]
/*
 * Note:
 * In arrays, indexes start at 0.
 * The first element has an index of 0, the second element has an index of 1.
*/

// Extract elements from a specific range and return them as a new array
const slicedColors = colors.slice(1, 3); // From index 1 up to, but not including, index 3

// Output the result
console.log(slicedColors); // Output: ['green', 'blue']

// The original array remains unchanged
console.log(colors); // Output: ['red', 'green', 'blue', 'orange', 'yellow']
arr.slice([start[, end]])
const numbers = [1, 2, 3, 4, 5];

// Extract the first three elements of the array
const firstThree = numbers.slice(0, 3);

console.log(firstThree); // Output: [1, 2, 3]

// Extract the last two elements of the array
const lastTwo = numbers.slice(-2);

console.log(lastTwo); // Output: [4, 5]
const fruits = ["apple", "banana", "cherry", "date", "elderberry"];

console.log(fruits.slice(2, 4)); // ['cherry', 'date']
// Extracts elements from index 2 ("cherry") up to, but not including, index 4 ("date").
const fruits2 = ["apple", "banana", "cherry", "date", "elderberry"];

console.log(fruits2.slice(2)); // ['cherry', 'date', 'elderberry']
// Extracts elements from index 2 ("cherry") to the end of the array.
const fruits3 = ["apple", "banana", "cherry", "date", "elderberry"];

console.log(fruits3.slice(-2)); // ['date', 'elderberry']
// Extracts elements starting from the second-to-last element to the end of the array.
const fruits4 = ["apple", "banana", "cherry", "date", "elderberry"];

console.log(fruits4.slice(2, 4)); // ['cherry', 'date']

// The original array remains unchanged
console.log(fruits4); // ['apple', 'banana', 'cherry', 'date', 'elderberry']