boolean Array.prototype.every(callbackfn:function[, thisArg:mixed=undefined])
Call the callbackfn for every element of the array using thisArg as context for callbackfn, but stop as soon as callbackfn returns false. In that sense, it will only process every element when they all calls to callbackfn (except possibly the last) return true. If and only if callbackfn ever returns false, so will every. Otherwise every returns true.
The callback function callbackfn should be a function that has the following fingerprint: boolean function(element:mixed, index:int, object:object)
The callback is not called for missing elements ([[HasProperty]]).
The this value will be coerced into an object (thisArg is not changed).
This function does not alter the array, but callbackfn is allowed to do so. The elements to be processed is determined before the first call to callbackfn so any changes to the order or array in general by callbackfn will not be reflected in the current call to every. The result of callbackfn is coerced to a boolean.
Array.prototype.every.length = 1
Array.prototype.every = function(callbackfn, thisArg){
var O = ToObject(this);
var lenValue = O.[[Get]]("length");
var len = ToUint32(lenValue);
if (!IsCallable(callbackfn)) throw TypeError;
if (arguments.length >= 2) var T = this.arg;
else var T = undefined; // actually, this line is not required ;)
var k = 0;
while (k < len) {
var Pk = ToString(k);
var kPresent = O.[[HasProperty]](Pk);
if (kPresent) {
var kValue = O.[[Get]](Pk);
var testResult = callbackfn.[[Call]](T, [kValue, k, O]);
if (!ToBoolean(testResult)) return false;
}
++k;
}
return true;
}
Note that for empty arrays every will return true.