Jump to navigation Jump to search
- Removes array element at the given 0-based index and returns removed element (modifies the original array, just like resize or set).
- array deleteAt index
- array: Array
- index: Number
- Return Value:
- Anything - returns the deleted element
- Example 1:
- Example 2:
- Example 3:
- See also:
- deleteRange set resize select in find findIf toArray toString forEach count pushBack pushBackUnique apply append sort param params arrayIntersect splitString joinString
- Posted on Oct 15, 2014 - 16:55 (UTC)
is almost 60x faster than_array deleteAt 0;
- Posted on Mar 04, 2016 - 15:58 (UTC)
- Deleting from an array with foreach and _foreachIndex variable is tricky. The array is being altered, the _foreachIndex won't keep up and other elements in the array will be skipped and in worst case not being deleted. If you delete elements from an array in descending order (using while or for) it will work.
- Posted on Feb 09, 2017 - 22:45 (UTC)
- To expand on Highheads comment above - this is because forEach implements iterators to traverse a collection, which are read only by definition. The variable _x is an iterator that points to the current item in the collection. Trying to alter _x will have no effect.
- Posted on Feb 01, 2021 - 18:06 (UTC)
As you would expect from a simple array implementation,
is very performance heavy (0.7ms on the same huge array).array deleteAt 0;