TypeError: redeclaration of let error in Firebug console if running ES6 code

后端 未结 1 1121
[愿得一人]
[愿得一人] 2021-02-19 14:19

I am learning ES6, so bear me please.

Following is the code which is running fine, if I click the Run button one time, but on second hit it starts showing

1条回答
  •  我寻月下人不归
    2021-02-19 14:31

    ES6 does not allow you to do this (redeclaring a block-scoped variable in the same scope):

    let foo;
    let foo;
    

    And since the console keeps state until you reload the page (you are in the context of the page after all), the first time you run it you define myArr so you cannot redefine it on the second run.

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