2
0
mirror of https://github.com/boostorg/test.git synced 2026-01-25 18:52:15 +00:00
Files
test/doc/js-lib/array_ex.js
Gennadiy Rozental 6c9bae63c6 added cookies
[SVN r14951]
2002-08-19 14:27:03 +00:00

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