Nodejs Array Any Predicate any(predicate, context)

Here you can find the source of any(predicate, context)

Method Source Code

Array.prototype.any = function (predicate, context) {
    context = context || window;/*  w ww.  j av  a  2  s . c  o m*/
    var f = this.some || function (p, c) {
        var l = this.length;
        if (!p) return l > 0;
        while (l-- > 0)
            if (p.call(c, this[l], l, this) === true) return true;
        return false;
    };
    return f.apply(this, [predicate, context]);
};

Related

  1. any(p)
    Array.prototype.any = function (p) {
     return this.filter(p).length > 0;
    };
    
  2. any(p)
    Array.prototype.any = function (p) {
      for (i = 0; i < this.length; i++)
        if (p(this[i])) return true;
      return false;
    };
    
  3. any(p)
    Array.prototype.any = function (p) {
      for(let el of this){
        if(p(el)) {return true;}
      return false;
    };
    
  4. any(p)
    Array.prototype.any = function (p) {
      for (var i = 0; i <this.length; i++){
        if (p(this[i]) === true){
          return true;
      return false;
    };
    
  5. any(predicate)
    Array.prototype.any = function(predicate){
      for (var i = 0; i < this.length; i++){
        if (predicate(this[i])) {
          return true
      return false
    
  6. any(searchItem)
    Array.prototype.any = function(searchItem){
      return this.filter(function(arrayItem){return arrayItem == searchItem}).length > 0;
    
  7. any(x)
    Array.prototype.any = function(x){
        var found = false;
        var i = 0;
        while(!found && i < this.length){
            if(typeof x === 'function'){
               if(x(this[i])){
                   found = true;
            }else if(x == this[i]){
    ...
    
  8. AnyT(lambda, t)
    Array.prototype.AnyT = function(lambda, t) {
        if (typeof (lambda) !== "function")
            throw new Error("lambda must be a function");
        for (var idx = 0; idx < this.length; idx++) {
            var obj = this[idx];
            if (typeof (obj) !== t)
                throw new Error("array items must be " + t + " types but " + obj + " is a " + typeof (obj));
            if (lambda(obj))
                return true;
    ...