Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript 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?

like image 937
Dylan Avatar asked Nov 25 '25 12:11

Dylan


1 Answers

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!