PROWAREtech
JavaScript: IE11 Array.find() Method/Function
Create the Array.find() function for Internet Explorer 11.
Still developing for IE11? Well, the find()
method returns the value of the first element that passes a test.
if (!Array.prototype.find) {
Array.prototype.find = function (func) {
if (this == null) {
throw new Error('this is null or not defined');
}
var O = Object(this);
var len = O.length >>> 0;
for (var i = 0; i < len; i++) {
if (func(O[i])) {
return O[i];
}
}
return undefined;
};
}
Comment