, , Array.forEach. polyfill, Array.forEach, , 10 1.
, Array.revEach Array.forEach, , , Array.forEach polyfill , .
Array.revEach out Array.forEach, 17 "Chrome 46.0.2490.22 beta-m"
if (Array.prototype.revEach === undefined) {
Object.defineProperty(Array.prototype, 'revEach', {
writable : false,
enumerable : false,
configurable : false,
value : function (func) {
var i;
var len = this.length-1;
for (i = len; i >= 0; i--) {
func(this[i], i, this);
}
}
});
}
polyfill, . .
if (!Array.prototype.revEach) {
Array.prototype.revEach = function(callback, thisArg) {
var T;
if (this == null) {
throw new TypeError(' this is null or not defined');
}
var O = Object(this);
var k = (O.length >>> 0)-1;
if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function');
}
if (arguments.length > 1) {
T = thisArg;
}
while (k >= 0) {
var kValue;
if (k in O) {
kValue = O[k];
callback.call(T, kValue, k, O);
}
k--;
}
};
}