Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Last active March 22, 2017 02:17
Show Gist options
  • Save StevenJL/1211e07da1c6161b9c480af5ded1700d to your computer and use it in GitHub Desktop.
Save StevenJL/1211e07da1c6161b9c480af5ded1700d to your computer and use it in GitHub Desktop.
ES6/constant
// `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