Answer:
Option D: monthName.splice(2, 3, "Mar", "Apr", "May");
Explanation:
splice is a JavaScript array method which can be used to insert or remove item(s).
It has general syntax: splice( i, n , item1, item2, item3, .... , itemX)
- i : index position of the array where the item should be inserted or removed
- n: number of item(s) should be removed starting from index-i
- item1,item2,....itemX : item(s) to be inserted
If we have an original monthName array with elements:
["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
monthName.splice(2, 3, "Mar", "Apr", "May") will
- remove 3 items from index position-2 ("March", "April" and "May")
- and insert three new items, "Mar", "Apr" and "May".
New array:
["January", "February", "Mar", "Apr", "May", "June", "July", "August", "September", "October", "November", "December"]