Es6 Flashcards
What is a code block? What are some examples of a code block?
if statement, loops, functions / code block {}
What does block scope mean?
variable defined within a block {} can not be accessed outside of the block
What is the scope of a variable declared with “const” or “let”?
block scope, var is a function scope
Why is it possible to .push() a new value into a const variable that points to an array?
const is storing a reference to the array, you’re not modifying the array
How should you decide which type of declaration to use?
Use Let if you want the variable to be mutable, use Const if variable can not be reassigned
What is the difference between Let and Const?
Use Let if you want the variable to be mutable, use Const if variable can not be reassigned
What is the syntax for writing a template literal?
using backticks `, \n\ for multi-line (when escaping to the next line), ${variableName}
What is “string interpolation”?
string formatting so that we can substitute a part of the string for values of variables or expressions
What is destructuring, conceptually?
taking apart something
What is the syntax Object destructuring?
const, opening curly brace, name of property, closing curly brace, assigned to the object
What is the syntax for Array destructuring?
const, [variables, variables, variables] assigned to arrayName
How can you tell the difference between destructuring and creating Object/Array literals?
var/const/let {} = objectName, var/const/let []= arrayName
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?
With {}, there must be a return statement, without just defines an arrow function. => expression VS. => { statements }
How is the value of this determined within an arrow function?
where the function is defined