es6-const-let Flashcards
What is a code block? What are some examples of a code block?
A block of code within curly braces. Examples: if else, for, do while, while, try catch, etc.
What does block scope mean?
The variable is accessible within the block that is between the curly braces
What is the scope of a variable declared with const or let?
They are block-scoped
What is the difference between let and const?
Let can be reassigned (they are mutable), const cannot be reassigned (immutable)
Why is it possible to .push() a new value into a const variable that points to an Array?
The values within the array are mutable
How should you decide on which type of declaration to use?
If the variable is not going to need to be reassigned, use ‘const’ (anything that can be a constant variable, should be). If it will need to be reassigned, then use ‘let’