Last active
March 22, 2017 02:17
-
-
Save StevenJL/1211e07da1c6161b9c480af5ded1700d to your computer and use it in GitHub Desktop.
ES6/constant
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
| // `const` creates an 'immutable variable', that is a variables which cannot be | |
| // re-assigned new content. Note this only makes the variable itself immutable, | |
| // not its assigned content (for instance, in case the content is an object, | |
| // this means the object itself can still be altered). | |
| const PI = 3.14159; | |
| // `let` creates a variable that is scoped to its nearest containing block. | |
| // Compare this to `var` which scopes a variable to its nearest containing | |
| // function. | |
| let name = "Steve"; | |
| // It's good practice to use either `const` or `let` in lieu of `var` if | |
| // ES6 is available. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment