es6-const-let-Q&A Flashcards
What is a code block? What are some examples of a code block?
JavaScript statements can be grouped together in code blocks, inside curly brackets {…}. The purpose of code blocks is to define statements to be executed together.
What does block scope mean?
Block scoped variables: A block scoped variable means that the variable defined within a block will not be accessible from outside the block.
What is the scope of a variable declared with const or let?
Block scope
What is the difference between let and const?
Both the let and the const keyword are ways to declare block scoped variables. There is one big difference though: Variables declared with let can be reassigned. Variables declared with const have to be initialized when declared and can’t be reassigned.
Why is it possible to .push() a new value into a const variable that points to an Array?
You can change the contents of the array but not change the actual value
How should you decide on which type of declaration to use?
If the variable needs to change use let, otherwise use const