+ 2
Is there an efficient way to remove a specific index from an array? (Javascript)
For example, say I have the array: "Enemies" with a length of 75, and I want to remove index number 46. How would I remove this in an efficient way?
3 Réponses
+ 9
Splice it using splice () method.
var arr = [0,1,2....your array]
arr.splice(45,1) // remove element with index 45. 1 is number of items which will be removed. For example, if You want to remove elements with 45,46 index, call arr.splice(45,2)
+ 4
var arr = […];
var arr2 = arr.join("!").replace(arr[46],"").split("!");
(tell me if it works…)
0
hey frnd wooh ur superb great.....hope I soon will be as much as u...