I tested Array.prototype.splice() and found that it's very slow on large arrays.
A much faster way of removing elements is to copy the ones you wish to keep to a new array, while skipping the ones you want to remove. After you've finished copying, you simply override the old array with the new one.
In my test I removed every other element from an array containing 100.000 items. The test compared Array.prototype.splice() to other methods. Here are the results:
855 ms = splice
7 ms = manual copying without preserving the original array
14 ms = manual copying with preserving the original array
Here's the code for the last method:
var arrB = [],
i=varA.length,
j=0;
// copy even items to a new array
while(i > 0) {
i-=2; // skip two elements
arrB[j++] = arrA[i];
}
// clear the old array
arrA.splice(0, arrA.length);
// copy values back to the old array
// array is preserved (references to the array don't need to be updated)
arrA.push.apply(arrA, arrB);
The test in action can be found on jsFiddle: http://jsfiddle.net/sansegot/eXvgb/3/
The results are much different if you only need to remove a few items - in such cases Array.prototype.splice() is faster (although the difference is not so large)! Only if you need to call splice() many times it's worth it to implement custom algorithm.
The second test, in which a limited number of elements are to be removed can be found here:
http://jsfiddle.net/sansegot/ZeEFJ/1/