Javascript Array indexOfObject(myArray, searchTerm, property)

Description

Javascript Array indexOfObject(myArray, searchTerm, property)


Array.prototype.indexOfObject = function (myArray, searchTerm, property) {
    for(var i = 0, len = myArray.length; i < len; i++) {
        if (myArray[i][property] === searchTerm) 
        return i;
    }//from w w w  .  ja  v  a  2 s .co  m
    return -1;
}



PreviousNext

Related