What is a code block? What are some examples?
a block of code contained by curly braces - loops, if conditions, functions
What does block scope mean?
let x = 10;
if (x = 10) {
let x = 20;
console.log(x); // 20: reference x inside the block
}
console.log(x); // 10: reference x at the beginning of the script
What is the scope of a variable declared with const or let?
block-scoped
What is the difference between let and const?
variables declared by const keyword cannot be reassigned
Why is it possible to .push( ) a new value into a const variable that points to an array?
The const variable is immutable but the values within the array aren’t immutable
How should you decide on which type of declaration to use? (const vs let)
- if the variable is never reassigned, use const
What is the syntax for writing template literals?
let example = ` this is a template literal `;
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions
- (the big difference between template literals and normal strings is substitution. string interpolation allows you to embed variables and expressions in a string. JS will automatically replace these variables/expressions with their values)
what is destructuring, conceptually?
makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
What is the syntax for object destructuring?
const {property1: variable1, property2: variable2,,} = objectName
What is the syntax for array destructuring?
let [element1, element2, element3,,] = arrayName
How can you tell the difference between destructuring and creating object/array literals?
- if creating object/array, brackets are on the right side of the =
What is the syntax for defining an arrow function?
const funcName = (parameter1, parameter2,…) => { code }
When an arrow functions body is left without curly braces, what changes in its functionality?
How is the value of this determined within an arrow function?
What are the three states a Promise can be in?
How do you handle fulfillment of a Promise?
How do you handle the rejection of a Promise?
What is “syntactic sugar”?
Describe ES6 class syntax:
class Name {
constructor(param1, param2,..) { Prototype method( ) {}}
What is refactoring?
How are ES6 modules different from CommonJS modules?
What kind of modules can Webpack support?