Internet Explorer上的Javascript语法错误 [英] Javascript syntax error on Internet Explorer

查看:59
本文介绍了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的转译器.

这篇关于Internet Explorer上的Javascript语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆