Unable to execute Array.prototype.find in IE / Edge
Hi,
I am using this to solve my problem for IE / Edge that does not support Array.find()
Below is my piece of code that i am using in my angular directive to find the element from array.
var found = scope.data.find(function(element, i) {
index = i;
return element.id === testObj.id;
});
Here scope.data is my json array and testObj is some random json which contains required id.
I am getting below error in IE / Edge.
Object doesn't support property or method 'find'
Any help?
How are you importing/requiring this module, and are you doing so before the rest of your application loads?
@ljharb I am adding this dependency in bower.json. After that i am using it in my angular directive. Do i need to import this dependency in the directive.js code? If yes, Than how?
This directive is being loaded on some click event (I am using Array.prototype.find in link function)
I'm not familiar with angular (and I'd suggest consuming deps from npm; bower's long since deprecated and dead). However, you need to load polyfills eagerly, before all other code in your application - not conditionally or on click.