Javascript Array any(predicate, context)

Description

Javascript Array any(predicate, context)


Array.prototype.any = function (predicate, context) {
    context = context || window;//from ww  w.  j  a va 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]);
};



PreviousNext

Related