Syntax Error Using => In Ie
I have the following line of javascript code var res = Object.keys(packages).filter(e => packages[e] === true) The above works well in all the other browser apart from IE. IE c
Solution 1:
IE must not support arrow-functions. Just use the old function
keyword.
.filter(function(e){ return packages[e] === true })
Side note, but you could also probably write this as:
.filter(function(e){ return packages[e] })
Unless packages[e]
must actually be exactly equal to true
and not just truthy.
Solution 2:
IE doesn't support the fat arrow notation (Edge does). See http://kangax.github.io/compat-table/es6/. You need the older function notation:
var res = Object.keys(packages).filter(function(e) { return packages[e] === true })
Solution 3:
CanIUse: Arrow function You cannot use it in IE;
var res = Object.keys(packages).filter(function(e) = {return packages[e] === true})
Post a Comment for "Syntax Error Using => In Ie"