Javascript Array select(lambda)

Description

Javascript Array select(lambda)


Array.prototype.select = function(lambda) {
    if (lambda == undefined) {
        return this;
    } else {//  w  w  w.j  a  v  a 2 s . c o  m
        result = [];
        for (i = 0; i < this.length; i++) {
            if (lambda(this[i])) {
                result.push(this[i]);
            }
        }
        return result;
    }
};



PreviousNext

Related