JavaScript ES6 Flashcards
What is a code block? What are some examples of a code block?
block of code inside curly braces
What does block scope mean?
only accessible inside the block
What is the scope of a variable declared with const or let?
block scoped variables
What is the difference between let and const?
const = x change
let = can change
Why is it possible to .push() a new value into a const variable that points to an Array?
not reassigning it, just changing its value
How should you decide on which type of declaration to use?
if reassignment is needed use let /
otherwise use const
What is the syntax for writing a template literal?
using backticks ` `
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions.
What is destructuring, conceptually?
taking properties of object out and assigning them to variables
What is the syntax for Object destructuring?
const book1 = { title: ‘Goodnight Punpun’, author: ‘Inio Asano’, libraryID: 3353 };
const { title, author, libraryID } = book1;
What is the syntax for Array destructuring?
const [x, y, z] = library;
How can you tell the difference between destructuring and creating Object/Array literals?
creating : variable left hand side
destructuring: variable right hand side
What is the syntax for defining an arrow function?
parameters => expression/return statement
When an arrow function’s body is left without curly braces, what changes in its functionality?
returns the result of the expression
How is the value of this determined within an arrow function?
Unlike an anonymous function, an arrow function captures the this value of the enclosing context instead of creating its own this context.