The splice() method of an array changes the array by removing or replacing existing elements and/or inserting new elements.

    
    const days = ['Mon','Tues','Wed','Thur','Fri'];

    // remove elements, start at index 3
    const removed = days.splice(3);

    console.log(days);
    // ["Mon", "Tues" "Wed"]
    console.log(removed);
    // ["Thur", "Fri"]

    // Replace
    const months = ['Jan', 'Feb', 'April', 'April']

    // at index 1, remove 1, add string(s)
    months.splice(2, 1, 'March');

    console.log(months);
    // ["Jan", "Feb", "March", "April"]

    // Insert
    const days1 = ['Mon','Tues','Thur','Fri'];

    // at index 2, remove 0, add string(s)
    days1.splice(2, 0, 'Wed');

    console.log(days1);
    // ["Mon", "Tues", "Wed", "Thur", "Fri"]