Fastest way to delete one entry from the middle of Array()

Tom picture Tom · Mar 12, 2009 · Viewed 45.9k times · Source

What is the fastest way to delete one specific entry from the middle of Array()

Array is large one having Strings.

I dont want just to set Array[5] = null, but instead array size should be reduced by one and array[5] should have content of array[6] etc.

Answer

kkyy picture kkyy · Mar 12, 2009

Don't have any benchmarks to support this, but one would assume that the native Array.splice method would be the fastest...

So, to remove the entry at index 5:

array.splice(5, 1);