mirror of
https://github.com/boostorg/test.git
synced 2026-01-25 18:52:15 +00:00
37 lines
784 B
JavaScript
37 lines
784 B
JavaScript
if( !Array.prototype.indexOf ) {
|
|
Array.prototype.indexOf = function( el ) {
|
|
for( var index = 0; index < this.length; ++index ) {
|
|
if( this[index] == el )
|
|
return index;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
if( !Array.prototype.contains ) {
|
|
Array.prototype.contains = function( el ) {
|
|
return this.indexOf( el ) != -1;
|
|
};
|
|
}
|
|
|
|
if( !Array.prototype.remove ) {
|
|
Array.prototype.remove = function( el ) {
|
|
var index = this.indexOf( el );
|
|
|
|
if( index > -1 ) {
|
|
//!! splice
|
|
for( var index2 = index+1; index2 < this.length; index2++ ) {
|
|
this[index2-1] = this[index2];
|
|
}
|
|
|
|
this.pop();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
}
|
|
|
|
// EOF
|