Javascript Array where(criteria)

Description

Javascript Array where(criteria)


Array.prototype.where = function (criteria) {
    var result = [];
    for (var i = 0; i < this.length; i++) {
        var item = this[i];
        if (criteria(item)) {
            result.push(item);/*from ww w  . j a  va  2 s. com*/
        }
    }
    return result;
};



PreviousNext

Related