JS-ARRAY-SPLICE
The JavaScript Array.splice() method offers the ability to either insert elements, remove elements, or do both at the same time.
array.splice( pos, delCount, ins0, ..., insN );The pos specifies the position in the array where the splice should begin. delcount specifies the number of array elements to be deleted. If delcount is not specified, splice will delete the rest of the array beginning at pos. If delcount is 0 then no elements will be deleted. After any deletion(s) have taken place, the ins0 through insN elements will be inserted at the pos position.
This method returns an array of the deleted elements or undefined if no elements were deleted.
If arr1 contains ['cat', 'dog', 'giraffe', 'pony'] then:
arr1.splice( 1, 2, 'parrot', 'pheasant', 'bull' );
will change arr1 to ['cat', 'parrot', 'pheasant', 'bull', 'pony'] and return ['dog', 'giraffe']. The following,
arr1.splice( 1, 1 )
would change arr1 to ['cat', 'giraffe', 'pony'] and return ['dog'].