Javascript Array select(predicate)

Description

Javascript Array select(predicate)


Array.prototype.select = function(predicate){
    var r = []//from  w ww . j av  a  2s . c  o m
    for(var n = 0; n < this.length; n++) {
        if(predicate(this[n])){
            r.push(this[n]);
        }
    }

    return r;
};



PreviousNext

Related