mirror of
https://github.com/photonstorm/phaser
synced 2025-01-01 15:58:48 +00:00
35 lines
754 B
JavaScript
35 lines
754 B
JavaScript
|
/**
|
||
|
* A polyfill for Array.forEach
|
||
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
|
||
|
*/
|
||
|
if (!Array.prototype.forEach)
|
||
|
{
|
||
|
Array.prototype.forEach = function (fun /*, thisArg */)
|
||
|
{
|
||
|
'use strict';
|
||
|
|
||
|
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 thisArg = arguments.length >= 2 ? arguments[1] : void 0;
|
||
|
|
||
|
for (var i = 0; i < len; i++)
|
||
|
{
|
||
|
if (i in t)
|
||
|
{
|
||
|
fun.call(thisArg, t[i], i, t);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|