最快要删除阵列中间的一个条目的方式()目的、阵列、方式

2023-09-09 21:33:40 作者:作业真是个磨人的小妖精

什么是删除阵列的中间()

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

阵列是大是具有字符串。

Array is large one having Strings.

我不想只是设置阵列[5] = NULL,而是数组的大小应该由一个和阵列降低[5]应该有数组[6]的内容等。

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.

推荐答案

没有任何标准来支持这一点,但人们会假设本机Array.splice方法是最快的...

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

所以,在索引5删除的条目:

So, to remove the entry at index 5:

array.splice(5, 1);