JS ES6 Flashcards
What is a code block? What are some examples of a code block?
A code block is the space between curly braces. Examples include the code block within function definitions. The code block of for loops and while loops.
What does block scope mean?
Block scope begins at the first curly brace. Any variables defined, or reassigned within block scope are only accessible within that block scope.
What is the scope of a variable declared with const or let ?
Their scope is block scope.
What is the difference between let and const ?
let can be reassigned, const can not be. const is a read only reference. let doesn’t have to be initialized to a value when declared… const does.
Why is it possible to .push() a new value into a const variable that points to an Array ?
because a const variable is read-only… the actual value referenced isn’t immutable
How should you decide on which type of declaration to use?
the declaration you use should be determined by whether or not a variable is intended to be reassigned or not
What is the syntax for writing a template literal?
strings and/or variables written between backticks ( ` ` )
What is string interpolation?
being able to substitute part of a string with values of variables or expressions
What is destructuring, conceptually?
The mass assignment of object properties / array values to variables.
What is the syntax for Object destructuring?
let { objProp1: var1, objProp2: var2 } = mainObj;
What is the syntax for Array destructuring?
let [ var1, var2, var3 ] = exArray;
How can you tell the difference between destructuring and creating Object/Array literals?
the side on which the curly braces/square brackets are on
What is the syntax for defining an arrow function ?
(p1,p2…) => {
}
When an arrow function’s body is left without curly braces, what changes in its functionality?
it becomes an implicit return value
How is the value of this determined within an arrow function?
this isn’t defined when the arrow function is called, it’s inherited from the parent scope