es6-const-let Flashcards
1
Q
What is a code block? What are some examples of a code block?
A
A block of statement within curly braces { };
Examples: if else, for, do while, while; function code block;
2
Q
What does block scope mean?
A
An area within the block where variables can be referenced
3
Q
What is the scope of a variable declared with const or let?
A
Let = block-scoped; Const = block-scoped
4
Q
What is the difference between let and const?
A
Const can’t be reassigned while let can.
5
Q
Why is it possible to .push() a new value into a const variable that points to an Array?
A
The value within the array is mutable
6
Q
How should you decide on which type of declaration to use?
A
If the variable is not going to be reassigned, use ‘const’. If it will be reassigned, then use ‘let’