Steven Daniel Anderson
Steven Daniel Anderson

Reputation: 1443

Different forms of using 'let'

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']

Upvotes: 8

Views: 299

Answers (1)

Alberto Trindade Tavares
Alberto Trindade Tavares

Reputation: 10356

  • 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 the one you want!

Upvotes: 11

Related Questions