es6-const-let Flashcards
What is a code block?
Code blocks are function declarations between an opening and closing curly brace. For loops, if else statement, while loops, etc
OR grouped statements within curly braces or any collection of curly braces.
What are some examples of a code block?
functions, objects
What does block scope mean?
It means that the area where declared variables exist and are available for use, usually within the confines of a code block
What is the scope of a variable declared with const or let?
Block scope. Only attached to the code block it exists in. A block is a chunk of code bounded by {}.
What is the difference between let and const?
The const variable cannot be reassigned or updated while let can
Why is it possible to .push() a new value into a const variable that points to an Array?
While it’s the object or array stored cannot be reassigned, they are not immutable as the value of each properties in a const variable can be reassigned.
How should you decide on which type of declaration to use?
Use const unless you can’t.
Will the value need to be attached to the global object? Use a var.
Will the value need to be reassigned only? Use a let.
Will the value not need to be reassigned only? Use a const.
Es6-destructuring