ARRAY Some extensions

xiaoxiao2021-03-05  24

Function Array.Prototype.Insert (data, index) {

IF (ISNAN (INDEX) || Index <0 || index> this.length) {

THIS [THIS.LENGTH] = DATA;

} else {

Var Temp = this.slice (Index-1);

THIS [index-1] = DATA;

For (var i = 0; i

}

}

Function Array.Prototype.InsertArray (Ary, INDEX) {

IF (ISNAN (INDEX) || Index <0 || index> this.length) {

FOR (var i = 0; i

THIS [this.Length] = ary [i];

} else {

Var Temp = ary.concat (this.slice (index-1));

For (var i = 0; i

}

}

Function Array.Prototype.Append (data, index) {

IF (Data InstanceOf Array) This.Insertaray (Data, Index 1);

Else this.insert (Data, INDEX 1);

}

Function array.prototype.indexof (data) {

For (var i = 0; i

IF (THIS [I] == DATA) RETURN I;

}

Function Array.Prototype.lastIndexof (data) {

For (var i = this.length-1; i> = 0; i -)

IF (THIS [I] == DATA) RETURN I;

}

Function Array.Prototype.Remove (a, b) {

Return this.slice (0, a) .concat (this.slice ((b || a) 1)))

}

转载请注明原文地址:https://www.9cbs.com/read-36094.html

New Post(0)