ES6 Flashcards
What is a code block? What are some examples of a code block?
A block of code, examples being Functions, Objects and Array
What does block scope mean?
Means the code inside is not accessible from outside the block. (What happens in the code block stays in the code block)
What is the scope of a variable declared with const or let?
Block Scope
What is the difference between let and const?
let values can be reassigned,
while a const values are read only
Why is it possible to .push() a new value into a const variable that points into an Array?
You are able to manipulate an array declared with const but you are unable to reassign it
How should you decide on which type of declaration to use?
Depending if you want to read only or reassign the variable, if you don’t know ALWAYS use const first
What is the syntax for writing a template literal?
Backsticks (
)
Newline (\n)
Newline continuation (\n)
Substitution ( ${expression} )
What is “string interpolation”
A combination of a string and outputs inside the string
What is restructuring, conceptually?
The breakdown of an array or object
What is the syntax for Object destructuring?
const or let [ var, var, var… ] = Object
What is the syntax for Array destructuring?
const or let {var, var, var… } = Array
How can you tell the difference between destructuring and creating Object/Array literals?
When creating an Object/Array the equal sign goes before the curly brace
When destructuring the equal sign goes after the curly brace
What is the syntax of an arrow function?
() => expression
param => expression
(param) => expression
(param1, paramN) => expression
() => {
statements
}
param => {
statements
}
(param1, paramN) => {
statements
}
When an arrow function’s body is left without curly braces, what changes its functionallity?
becomes an expression rather than a statement
How is the value of this determined within an arrow function?
Within an arrow function the this is not binded to the function