JS pit value splice and delete methods (array)

Today encounter a pit in the development of projects, operations of an hour to no avail, after various breakpoints during eventually found loopholes for their own grasp js.

The following are the specific circumstances:

To delete an array element we will generally use delete (); but this removal of remains removed elements of the position, but it becomes a undifned;

If using splice (index, 1), will be deleted from the index index of an element, the elements behind will move forward, elements erased location is no longer reserved.

A lesson.

Guess you like

Origin www.cnblogs.com/ttty/p/11685280.html