add JS implementation for forEach
This commit is contained in:
parent
ac923b5813
commit
b817889ad8
1 changed files with 21 additions and 1 deletions
|
|
@ -87,6 +87,26 @@ if (!Array.prototype.indexOf)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from MDC
|
||||||
|
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
|
||||||
|
if (!Array.prototype.forEach) {
|
||||||
|
Array.prototype.forEach = function(fun /*, thisp */) {
|
||||||
|
if (this === void 0 || this === null)
|
||||||
|
throw new TypeError();
|
||||||
|
|
||||||
|
var t = Object(this);
|
||||||
|
var len = t.length >>> 0;
|
||||||
|
if (typeof fun !== "function")
|
||||||
|
throw new TypeError();
|
||||||
|
|
||||||
|
var thisp = arguments[1];
|
||||||
|
for (var i = 0; i < len; i++) {
|
||||||
|
if (i in t)
|
||||||
|
fun.call(thisp, t[i], i, t);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of keys on an object.
|
* Retrieves the list of keys on an object.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue