SyntaxError:missing =在const声明Firefox 50中 [英] SyntaxError: missing = in const declaration Firefox 50

查看:860
本文介绍了SyntaxError:missing =在const声明Firefox 50中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下循环:

const bar = {a: 1, b: 2}
for (const k in bar) { //Throws in Firefox but not Chrome 54
    console.log(k)
}

这是一个bug吗?或者可能是规范中的灰色区域?

Is this a bug? Or maybe a gray area in the spec?

推荐答案

是的,这似乎是Firefox中的一个错误。 规范允许使用 const

Yes, this appears to be a bug in Firefox. The spec allows the use of const:

IterationStatement:
    for(ForDeclaration in Expression) Statement

ForDeclaration:
    LetOrConst ForBinding

ForBinding:
    BindingIdentifier
    BindingPattern

(截断和简化)

似乎Firefox不正确地将解释为 LexicalBinding

It seems Firefox is incorrectly interpreting ForDeclaration as a LexicalBinding.

相关: ECMAScript 2015: const in for循环

这似乎是针对此问题的错误报告: https:// bu gzilla.mozilla.org/show_bug.cgi?id=1101653

This seems like the bug report for this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1101653 .

正确 const 来到Firefox: https://twitter.com/evilpies/status/768881995912994816

Proper let and const is coming to Firefox: https://twitter.com/evilpies/status/768881995912994816

这篇关于SyntaxError:missing =在const声明Firefox 50中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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