I get a error message in IE11 but not in chrome the error is:
Script1002 Syntax error
My code is as follows
var selectedRoles = vm.roles.filter(x => x.id === role.id);
The line and column number of the error suggest that it is the arrow function =>
that IE11 does not like. However it works fine in Chrome and Edge
IE11 does not support the arrow notation for anonymous functions.
It's a new feature that introduced in ES6 and is called arrow function. The left part denotes the input of a function and the right part the output of that function.
One can use filter() function in JavaScript to filter the object array based on attributes. The filter() function will return a new array containing all the array elements that pass the given condition. If no elements pass the condition it returns an empty array.
ES6 - Array Method filter() filter() method creates a new array with all elements that pass the test implemented by the provided function.
ie 11 not support arrow functions
try
var selectedRoles = vm.roles.filter(function(x) { return x.id === role.id; });
IE not supported arrow function check browser compatibility here. If you want IE support then use the normal function instead.
var selectedRoles = vm.roles.filter(function(x) { return x.id === role.id });
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