Different forms of using 'let'

时间:2017-08-05 10:36:33

标签: javascript

I saw a tutorial for JavaScript ES6 in which the guy used this syntax to assign a value with let:

let = name = ['Jhon','Paul','Ean']

What is the difference between the first and this:

let name = ['Jhon','Paul','Ean']

1 个答案:

答案 0 :(得分:10)

  • The first one is creating two global variables: let and name, and assigning the array first to name and then to let. It is not what you want for sure.

  • The second one creates a block scope local variable called name. This is one what you want!