Nodejs Utililty Methods Array Any Predicate

List of utility methods to do Array Any Predicate

Description

The list of methods to do Array Any Predicate are organized into topic(s).

Method

any()
Array.prototype.any = function() {
  var i, _i, _len;
  for (_i = 0, _len = this.length; _i < _len; _i++) {
    i = this[_i];
    if (i) {
      return true;
  return false;
...
any()
Array.prototype.any = function(){
  return(this.length > 0);
};
any()
Array.prototype.any = function () {
  return this.length > 0;
any(conditionFunction)
Array.prototype.any = function(conditionFunction) {
    try {
        this.each(function(element) {
            if (conditionFunction(element)) {
                throw 'found!';
        });
        return false;
    } catch(e) {
...
any(delegate)
Array.prototype.any = function(delegate) {    
  for (var i=0; i < this.length; i++) {      
    if (delegate.apply(this, [this[i]]) === true) {
      return true;
  return false;  
};
any(func)
Array.prototype.any = function (func) {
    var length = this.length;
    for (var i = 0; i < length; i++) {
        if (func(this[i]))
            return true;
    return false;
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;
};
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;
any(p)
Array.prototype.any = function (p) {
  for (var i = 0; i < this.length; i++) {
    if(p(this[i]) == true){
      return true;
  };
  return false;
};
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));