Nodejs Array Any Predicate any(p)

Here you can find the source of any(p)

Method Source Code

Array.prototype.any = function (p) {
  for (i = 0; i < this.length; i++)
    if (p(this[i])) return true;
  return false;// w w w  .j av  a  2 s .  com
};

Related

  1. any(p)
    Array.prototype.any = function (p) {
        var count = 0
        for (var i = 0 ; i < this.length ; i++) {
          currentIndex = this[i]
          if (p(currentIndex) === true) {
            console.log(p(currentIndex),"true is true")
            count +=1 
          };
        if (count > 0) {
          return true
        return false
    };
    Array.prototype.any = function (p) {
      return this.filter(p).length > 0;
    };
    
  2. any(p)
    Array.prototype.any = function(p) {
        var count = 0
        for (var i = 0; i < this.length; i++) {
            currentIndex = this[i]
            if (p(currentIndex) === true) {
                console.log(p(currentIndex), "true is true")
                count += 1
            };
        if (count > 0) {
            return true
        return false
    };
    function isGreaterThanZero(num) {
        return num > 0;
    function isLessThanZero(num) {
        return num < 0;
    
  3. any(p)
    Array.prototype.any = function (p) {
      for (var i = 0; i < this.length; i++) {
        if(p(this[i]) == true){
          return true;
      };
      return false;
    };
    
  4. any(p)
    Array.prototype.any = function (p) {
      for(var i = 0; i < this.length; i++){
        if(p(this[i])) return true;
      return false;
    };
    function isGreaterThanZero (num) {
      return num > 0;
    function isLessThanZero (num) {
      return num < 0;
    console.log([-1, 2, 3].any(isGreaterThanZero)); 
    console.log([-1, -2, -3].any(isGreaterThanZero)); 
    
  5. any(p)
    Array.prototype.any = function (p) {
     return this.filter(p).length > 0;
    };
    
  6. any(p)
    Array.prototype.any = function (p) {
      for(let el of this){
        if(p(el)) {return true;}
      return false;
    };
    
  7. any(p)
    Array.prototype.any = function (p) {
      for (var i = 0; i <this.length; i++){
        if (p(this[i]) === true){
          return true;
      return false;
    };
    
  8. any(predicate)
    Array.prototype.any = function(predicate){
      for (var i = 0; i < this.length; i++){
        if (predicate(this[i])) {
          return true
      return false
    
  9. any(predicate, context)
    Array.prototype.any = function (predicate, context) {
        context = context || window;
        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;
        };
    ...