Array. Prototype. Del = function (N)
{
If (n <0) return this;
Return this. Slice (0, n). Concat (this. Slice (n + 1, this. Length ));
}
// Shuffling the Array
Array. Prototype. Random = function ()
{
VaR Nr = [], Me = This, T;
While (Me. length> 0)
{
NR [Nr. Length] = me [T = math. Floor (math. Random () * Me. Length)];
Me = me. Del (t );
}
Return NR;
}
// Sort the number Array
Array. Prototype. sortnum = function (f)
{
If (! F) f = 0;
If (F = 1) return this. Sort (function (a, B) {return B-;});
Return this. Sort (function (a, B) {return a-B ;});
}
// Obtain the numeric entry of the number Array
Array. Prototype. getmax = function ()
{
Return this. sortnum (1) [0];
}
// Obtain the minimum entry of the number Array
Array. Prototype. getmin = function ()
{
Return this. sortnum (0) [0];
}
// The position where the specified Element value appears for the first time in the array
Array. Prototype. indexof = function (o)
{
For (VAR I = 0; I <this. length; I ++) if (this [I] = O) return I;
Return-1;
}
// Remove repeated items from the array
Array. Prototype. removerepeat = function ()
{
This. Sort ();
VaR rs = [];
VaR Cr = false;
For (VAR I = 0; I <this. length; I ++)
{
If (! Cr) Cr = This [I];
Else if (Cr = This [I]) RS [RS. Length] = I;
Else Cr = This [I];
}
VaR Re = this;
For (VAR I = Rs. Length-1; I> = 0; I --) Re = Re. Del (RS [I]);
Return re;
}
Example:
VaR arr = ["Ni", "wo", "ta"];
Delete "wo" from the array"
VaR newarr = arr. Del (1 );
Returns the position where "me" appears for the first time in the array. If not,-1 is returned.
VaR strpos = arr. indexof ("me ");