ES6 Flashcards
What is a code block? What are some examples of a code block?
Code blocks are usually found in loops or functions
Curly braces
What does block scope mean?
Block scope means it is only available in the local code block
What is the scope of a variable declared with const or let?
Block scoped ALWAYS
What is the difference between let and const?
let can be reassigned a value but const is immutable (except array and objects) since they are pointing to a memory address
Why is it possible to .push() a new value into a const variable that points to an Array?
because they are pointing to a memory address
How should you decide on which type of declaration to use?
const for most part but if the variable changes throughout the block then use let
What is destructuring, conceptually?
destructuring is assigning variables the value of the object properties
What is the syntax for Object destructuring?
const {var1, var2, var3, …} = objectName
What is the syntax for Array destructuring?
const [var1, var2, var3, …] = arrayName
How can you tell the difference between destructuring and creating Object/Array literals?
destructuring has brackets on the left-hand side whereas creating Object/Array literals will have them on the right-hand side
What is the syntax for writing a template literal?
use back ticks and ${} (dollar sign and curly braces)
What is “string interpolation”?
it is brining the value of variables into a string
What is the syntax for defining an arrow function?
() => {}
When an arrow function’s body is left without curly braces, what changes in its functionality?
implicit return fires
How is the value of this determined within an arrow function?
it encloses the actual ‘this’ and does not create it’s own ‘this’