SyntaxError: missing = in const declaration Firefox 50

后端 未结 1 1360
孤独总比滥情好
孤独总比滥情好 2021-01-08 00:11

I have a loop like the following:

const bar = {a: 1, b: 2}
for (const k in bar) { //Throws in Firefox but not Chrome 54
    console.log(k)
}
<
相关标签:
1条回答
  • 2021-01-08 01:00

    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
    

    (truncated and simplified)

    It seems Firefox is incorrectly interpreting ForDeclaration as a LexicalBinding.

    Related: ECMAScript 2015: const in for loops

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


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

    0 讨论(0)
提交回复
热议问题