ES6 Flashcards
What is a code block? What are some examples of a code block?
Code surrounded by curly braces. Ex: if statement, function, for loop
What does block scope mean?
the block scope restricts the variable that is declared inside a specific block
What is the scope of a variable declared with const or let?
block scope
What is the difference between let and const?
const is a var that cannot be reassigned while let is able to be reassigned
Why is it possible to .push() a new value into a const variable that points to an Array?
you aren’t reassigning a new array, you are just pushing a new value inside
How should you decide on which type of declaration to use?
If you want to change the var use let, if you don’t want to change use const
What is the syntax for writing a template literal?
back ticks instead of quotes
What is “string interpolation”?
process in which an expression is inserted or placed in the string.
What is destructuring, conceptually?
how you get property values or array elements all on one line
What is the syntax for Object destructuring?
keyword const or let, curly braces and property and variable names inside curly braces and object it came from
What is the syntax for Array destructuring?
keyword const or let, square brackets and property and variable names inside square brackets and object it came from
How can you tell the difference between destructuring and creating Object/Array literals?
if curly braces or square brackets are on left side of assignment operator then you are destructuring
What is the syntax for defining an arrow function?
const or let then varName = (parameter) => {code block}
When an arrow function’s body is left without curly braces, what changes in its functionality?
it does not require a return statement
How is the value of this determined within an arrow function?
It is the parents code block