Nodejs Array Where where(_cond)

Here you can find the source of where(_cond)

Method Source Code

Array.prototype.where = function (_cond) {

    var items = []; 
    for (var l = 0; l < this.length; l++) {
        if (_cond(this[l])) {
            items.push(this[l]);/*w ww  .  j a v  a 2 s . com*/
        }
    }
    return items;
};

Related

  1. where(argument)
    Array.prototype.where = function(argument) {
      return this.filter(item => argument(item));  
    };
    
  2. where(attribut, value)
    Array.prototype.where = function (attribut, value) {
        var res = [];
        for (var i = 0; i < this.length; i++) {
            if (this[i][attribut] == value)
                res.push(this.slice(i, i + 1));
        return res;
    };
    
  3. where(callback)
    Array.prototype.where = function(callback){
      if(!callback) return;
      for(var i = 0; i < this.length; i++){
        if(callback(this[i])){
          return this[i];
    
  4. where(exp)
    Array.prototype.where = function(exp){
        var exp = new Function("$", "return " + exp);
        var arr=[];
        for(var i=0; i<=this.length-1; i++){
            if(exp(this[i])){
                arr.push(this[i])
        return arr;
    ...