es6-const-let Flashcards
What is a code block? What are some examples of a code block?
Code within two { }… for, while, if, etc
What does block scope mean?
Variables only work within a specific code block.
What is the scope of a variable declared with const or let?
Let keywords are block-scoped. Const is read only block-scope variable.
What is the difference between let and const?
Let can change, while const remains fixed. Const also needs to be initialized.
Why is it possible to .push( ) a new value into a const variable that points to an array?
Variable only holds a pointer to a memory… You can make modifications.
How should you decide on which type of declaration to use?
Depending on if you want to change a value or a variable later or not. Always use const, and if you can’t, use let. Use let in a loop…. in an if statement, you can use let. Otherwise, always use const.