es6-const-let Flashcards
- What is a code block? What are some examples of a code block?
blocks are denoted by curly braces {}
functions, if statements, loops
What does block scope mean?
Inside the code block.
What is the scope of a variable declared withconstorlet?
Block scoped.
What is the difference betweenletandconst?
The const keyword creates block-scoped variables whose values can’t be reassigned.
The variables declared by the let keyword are mutable. It means that you can change their values anytime you want
Why is it possible to.push()a new value into aconstvariable that points to anArray?
actual value to which the const variable reference is not immutable.
We can change the array element
6
How should you decide on which type of declaration to use?
By figuring out if the value will need to be reassigned.
Favor const over let.
Let lets you know the variable will be reassigned.