Created
March 23, 2016 01:48
-
-
Save lricoy/7630fef0121058b2e190 to your computer and use it in GitHub Desktop.
ES2015 let and const
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function f() { | |
| { | |
| let x; | |
| { | |
| // ok, declarado no escopo | |
| const x = "sneaky"; | |
| // erro, o valor é uma constante | |
| x = "foo"; | |
| } | |
| // ok, declarado com `let` no escopo atual (linha 3) | |
| x = "bar"; | |
| // erro, já declarada no bloco (linha 3) | |
| let x = "inner"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment