cocos-enhance-kit/engine/polyfill/array.js

27 lines
630 B
JavaScript
Raw Permalink Normal View History

2022-06-24 16:23:03 +00:00
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;
};
}