Reputation: 11861
I have this site and in Internet Explorer I get this syntax error in IE only, Chrome its fine.
SCRIPT1002: Syntax error
File: communities.js, Line: 157, Column: 55
Line 157 is this: priceArray = priceArray.filter(x => x != $(this).val());
Here is the whole code, but IE wont tell me what the syntax error is.
$('ul.dropdown-menu input[type=checkbox]').each(function () {
$(this).change(function () {
if ($(this).attr("id") == 'price') {
if (this.checked) {
priceArray.push($(this).val());
}
else {
priceArray = priceArray.filter(x => x != $(this).val());
}
}
});
});
What am I doing wrong and how do I fix it?
priceArray is defined at the top of the file:
var priceArray = [];
Upvotes: 0
Views: 1802
Reputation: 7285
As Santi pointed out in the comments, IE does not support arrow functions.
The solution is to use a normal function. Normal functions however have their own this
object, so you have to give filter
the object that the provided function should be called with:
// ...
priceArray = priceArray.filter(function (x) {
return x !== $(this).val();
}, this);
// ...
Upvotes: 1