cocos-enhance-kit/engine/polyfill/array.js
2022-06-25 00:23:03 +08:00

27 lines
630 B
JavaScript

if (!Array.isArray) {
Array.isArray = function (arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
if (!Array.prototype.find) {
Array.prototype.find = function (callback) {
var length = this.length;
for (var i = 0; i < length; i++) {
var element = this[i];
if (callback.call(this, element, i, this)) {
return element;
}
}
return undefined;
};
}
// for ie 11
if (!Array.prototype.includes) {
Array.prototype.includes = function (value) {
return this.indexOf(value) !== -1;
};
}