Let
The let
keyword is similar to var
but with some key differences.
Let keyword
In JavaScript we can store a value in a variable with the var
keyword.
Now if we do the exact same thing with let
…
Why is x
undefined?
Let variables are scoped to the BLOCK
The block
is marked by {}
.
By contrast var
scopes to the function.
Exercise: Now you try it.
Nice job! On to the next lesson.