Example 1 : First find the index of element you need to remove.
var array = [6, 9, 4,3];
var indx = array.indexOf(4);
array.indexof method return the index of element 4 then use splice method to removed the particular element from the array.
it will removed one item to given index number and the Output is 6 9 3.
Example 2: At position 2 add two new items and removed 1 items.
var countries = [“Pakistan”, “USA”, “England”, “New Zealand “];
countries.splice(2, 1, “Iran”, “Poland”);
Result: Pakistan, USA, New Zealand, Iran, Poland.
First parameter is an Index of element where you want to adds or removes items.
Second parameter is used to tell how many number of items to be removed.
Last parameter is optional: Number of new item(s) to be added in an array.