How can i replace find method. It is used incorrectly. IE don't see var mail.
var mail = textObj.products.find(function ( itm ) { return itm.name == c }).mail
Array.prototype.find() is not yet supported in IE and Opera (source).
If you want to use it, you should insert the Polyfill function for it:
if (!Array.prototype.find) {
Array.prototype.find = function(predicate) {
if (this === null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
};
}
Alternatively, you can use the Array.prototype.filter() function , which is available in IE9 (and up).
This is experimental technology and is not supported by every browser. You should use filter instead:
textObj.products.filter(function ( itm ) { return itm.name == c })[0].mail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With