Nodejs Array Where where(func)

Here you can find the source of where(func)

Method Source Code

Array.prototype.where = function (func) {
    var items = [],
        length = this.length;

    for (var i = 0; i < length; i++) {
        if (func(this[i]))
            items.push(this[i]);/*from  w w  w  . j a va2s . c  om*/
    }

    return items.length === 0 ? null : items;
}

Related

  1. 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;
    ...
    
  2. where(f)
    Array.prototype.where = function(f){
       var fn = f;
       if(typeof f == 'string'){
          if((fn=lambda(fn)) == null){
             throw "Syntax error in lambda string: "+ f;
    };
    
  3. where(f)
    Array.prototype.where = function(f){
        var newArray = [];
        for(var i = 0; i < this.length; i++){
            if(f(this[i])){
                newArray.push(this[i]);
        return newArray;
    };
    ...
    
  4. where(func)
    Array.prototype.where = function(func) {
      var result = [];
      for (var i = 0; i < this.length; i++)
        if (func(this[i]))
          result.push(this[i]);
      return result;
    };
    
  5. where(func)
    Array.prototype.where = function(func){
      var result = [];
      forEach(this, function (element) {
        if(func(element)){
          result.push(element);
      });
      return result;
    
  6. where(inclusionTest)
    Array.prototype.where = function (inclusionTest) {
        var results = [];
        for (var i = 0; i < this.length; i++) {
            if (inclusionTest(this[i]))
                results.push(this[i]);
        return results;
    };
    Array.prototype.select = function (projection) {
    ...
    
  7. where(inclusionTest)
    Array.prototype.where = function (inclusionTest) {
        var results = [];
        for (var i = 0; i < this.length; i++) {
            if (inclusionTest(this[i]))
                results.push(this[i]);
        return results;
    };
    
  8. where(predicate)
    Array.prototype.where = function(predicate) {
        var derivedArray = [];
        for (i = 0; i < this.length; i += 1) {
            if (predicate(this[i])) {
                derivedArray.push(this[i]);
        return derivedArray;
    
  9. where(predicate)
    Array.prototype.where = function (predicate) {
        if (predicate == null || typeof (predicate) !== 'function') throw new Error('predicate should');
        var result = [];
        for (var i = 0; i < this.length; i++) {
            if (predicate(this[i], i)) result.push(this[i]);
        return result;
    };