Javascript Array findByProperty(propName, value)

Description

Javascript Array findByProperty(propName, value)


Array.prototype.findByProperty = function (propName, value) {
    if (this.length > 0) {
        for (var i = this.length - 1; i > -1; i--) {
            var propObj = this[i];
            if (propObj[propName] === value) {
                return propObj;
            }//from  ww w .  j a v a  2 s  .co  m
        }
    }
    return null;
};



PreviousNext

Related