Nodejs Array Reject reject(fun)

Here you can find the source of reject(fun)

Method Source Code

Array.prototype.reject = function(fun) {
  return this.reduce(function(res, el) {
    if(!fun(el)) {
      res.push(el);/*from   w  w w.  j a  v  a  2  s.  c om*/
    };
    return res;
  }, []);
}

Related

  1. reject(array)
    Array.prototype.reject = function(array) {
        return $.map(this, function(ele) {
            return $.inArray(ele, array) < 0 ? ele : null;
        })
    
  2. reject(callback)
    Array.prototype.reject = function(callback) {
      var arr = [];
      var length = this.length;
      if ( length < 0 )
        length = 0;
      for (var i = 0; i < length; i++)
        if ( i in this )
          if (!callback(this[i]))
            arr.push(this[i]);
    ...
    
  3. reject(callback)
    Array.prototype.reject = function(callback) {
      var arr = []
      var length = this.length
      if (length < 0) length = 0
      for (var i = 0; i < length; i++) {
        if (i in this)
          if (!callback(this[i]))
            arr.push(this[i])
      return arr