add indexOf() function to array - returns first index of a given element in an array. useful for testing, etc
git-svn-id: http://svn.openlayers.org/trunk/openlayers@225 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -519,7 +519,22 @@ Array.prototype.clear = function() {
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object} element
|
||||
*
|
||||
* @returns The first index of the element in the array if found. Else returns -1
|
||||
* @type int
|
||||
*/
|
||||
Array.prototype.indexOf = function(element) {
|
||||
var index = -1;
|
||||
for(var i=0; i < this.length; i++) {
|
||||
if (this[i] == element) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* zIndex is NOT set
|
||||
|
||||
Reference in New Issue
Block a user