ES6 Flashcards
What is a code block? What are some examples of a code block?
Anything enclosed in {}, example: if-else, for, do-while, while, try-catch.
What does block scope mean?
Variables or data that exists within the block
What is the scope of a variable declared with const or let?
block-scoped
What is the difference between let and const?
Const variables cannot be reassigned, the values or properties inside a const variable can be changed but the not value of the variable cannot be reassigned.
Why is it possible to .push() a new value into a const variable that points to an Array?
Because const only sets a freeze to the top layer of a variable, the values inside of a const variable can change but not the variable itself.
How should you decide on which type of the declaration to use?
Depending on the scope and how the variable will be used later on.
What is the syntax for writing a template literal?
backtick with the variable names in {} and $. Ex: Hi my name is ${firstName} ${lastName}
-> ‘Hi my name is Jumanah Almajnouni’
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions