mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-25 19:28:28 +00:00
27 lines
630 B
JavaScript
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;
|
|
};
|
|
}
|