DTmann DTmann - 4 years ago 172
HTML Question

Javasciprt syntax error on Internet Explorer

I have the following bit of code which adjusts the headers of some parsed data:

var parsedData = transposed.map(row =>
row.reduce((acc, col, ind) => {
acc[headers[ind]] = col;
return acc;
}, { }));

The code works fine on Chrome/Edge/Firefox but fails on Internet Explorer saying there's a syntax error at: row =>.

I'm unable to determine where the syntax error is being thrown - I'm relatively new to javascript's map function so I may be missing something. Where in the above code snippet is the syntax error?

Thanks in advance!

Answer Source

Arrow functions are a core part of the ES6 language feature set.

Those are not directly supported in IE, you need to transpile your code first.

Babel is the go-to transpiler for ES6.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download