ES6 Flashcards
What is a code block? What are some examples of a code block?
blocks are denoted by curly braces {} , for example, the if else, for, do while, while, try catch
What does block scope mean?
the variable only exists within the block
What is the scope of a variable declared with const or let?
blocked-scope
What is the difference between let and const?
let variables can be updated but not re-declared; const variables can neither be updated nor re-declared.
Why is it possible to .push() a new value into a const variable that points to an Array?
you can mutate the value of the const read-only reference but you cannot reassign it or redeclare it
How should you decide on which type of declaration to use?
for global use var, for block-scope use let/const
What is the syntax for writing a template literal?
wrap text in backticks
What is “string interpolation”?
${variable_name}
What is destructuring, conceptually?
assigning properties of objects to variables
What is the syntax for Object destructuring?
const { property1: variable1, property2: variable2 } = object;
What is the syntax for Array destructuring?
const [x, y, z] = array
How can you tell the difference between destructuring and creating Object/Array literals?
the name is on the right of assignment operator for CREATING objects/arrays.
the name is on left for DESTRUCTURING objects/arrays.
What are the three states a Promise can be in?
pending, fulfilled, rejected
How do you handle the fulfillment of a Promise?
Promise.prototype.then()
How do you handle the rejection of a Promise?
Promise.prototype.catch()