JavaScript method:splice. The most unused function ever
As it turns out , JavaScript Array type (Or actually prototype) has a method called "splice".
I don't think many programmers out there ever heard of this function.
The signature for this function is: splice(start, delCount, [arg1[,arg2[,…]]]) and what it does it:
Deletes from array delCount elements starting at position start, Replaces the deleted elements with optional arguments provided after delCount. Lets see some sample:
var oScriptionARR = new Array("Lets","Do","Some","Simple","Scripting");
oScriptionARR.splice(2, 2,"good","javascript");
alert(oScriptionARR);
In this sample the result will be "Lets Do good javascript Scripting". What happened here is that 2 elements from the position 2 in the array were deleted and replaced with the 2 given arguments.
I will be very happy to hear if anyone ever used this method?