Internet Explorer上的Javascript语法错误

问题描述:

我有以下代码可调整某些已解析数据的标头:

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;
        }, { }));

该代码在Chrome/Edge/Firefox上正常运行,但在Internet Explorer上失败,并指出在 row => 处存在语法错误.

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

我无法确定在哪里引发语法错误-我对javascript的map函数比较陌生,因此我可能会遗漏一些东西.上面的代码片段中语法错误在哪里?

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?

箭头功能是ES6语言功能集的核心部分.

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

IE中不直接支持这些代码,您需要先转换代码.

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

Babel 是ES6的转译器.