xxxxxxxxxx
// 1. Using the splice method to remove elements from an array
let array = [1, 2, 3, 4, 5];
let index = 2; // Index of the element to be removed
let count = 2; // Number of elements to be removed
array.splice(index, count);
console.log(array); // Output: [1, 2, 5]
// 2. Using the slice method to extract a portion of an array
let originalArray = [1, 2, 3, 4, 5];
let newArray = originalArray.slice(2); // Extract elements starting from index 2 till the end
console.log(newArray); // Output: [3, 4, 5]