Apply predicate for each array - Node.js Array

Node.js examples for Array:Array Operation

Description

Apply predicate for each array

Demo Code


Array.prototype.where = function (predicate) {
    var ret = [];
    for (var i = 0; i < this.length; ++i) {
        if (predicate(this[i], i))
            ret.push(this[i]);//  w w  w  .  j  ava  2s  . c  o m
    }
    return ret;
};

Related Tutorials