Knowledge debris - splice () method

 Splicing array:

Definition and Usage:

splice () method to add / remove items to the array

! ! This method will change the original array

parameter description
index essential. Integer, regulations add / remove items of location, may require the use of a negative position from the end of the array
howmany essential. To delete an item number, should 0, it will not be deleted
item1,item2...itemX Optional. Add a new item to the array

For the Code chestnut:

1) Adding elements

 

2) Add and remove elements

These elements are removed to replace it with the added element

 

Guess you like

Origin www.cnblogs.com/wtzmz/p/12535821.html