es6 Flashcards
What is a code block? What are some examples of a code block?
a chunk of code contained by {}. Examples include function definition, if/else statements, for loops
What does block scope mean?
block = code block. variables are not accessible outside of the block they were declared in
What is the scope of a variable declared with const or let?
the block where it was declared (block-scope)
What is the difference between let and const?
const cannot be reassigned
Why is it possible to .push() a new value into a const variable that points to an Array?
const variables can still be modified in certain ways, but they cannot be reassigned/redeclared
How should you decide on which type of declaration to use?
depending on how it will be used
What is the syntax for writing a template literal?
like a string but ${different}
What is “string interpolation”?
the ability to substitute part of a string for the values of variables or expressions
What is destructuring, conceptually?
Taking the values from an array/object and creating individual variables for them
What is the syntax for Object destructuring?
let { property1: variable1, property2: variable2 } = object;
What is the syntax for Array destructuring?
let [x, y, z] = array;
How can you tell the difference between destructuring and creating Object/Array literals?
look at what’s on which side of the =
What is the syntax for defining an arrow function?
const doSomething = (parameter1, parameter2) => { code goes here; }
When an arrow function’s body is left without curly braces, what changes in its functionality?
implicit return
How is the value of this determined within an arrow function?
this is pulled from the enclosing context