ES6 Flashcards
What is a code block? What are some examples of a code block?
Its code within curly braces that are contained within its own block.
What does block scope mean?
Usually concerned about its functions and variables accessible only within its function or block.
What is the scope of a variable declared with const or let?
Its block scope.
What is the difference between let and const?
Const is not reassigned whereas let is reassigning. A good language will prevent bugs so const will prevent bugs. Linttimeerror.
Why is it possible to .push() a new value into a const variable that points to an Array?
const makes constant references not constant values so its values are mutable.
How should you decide on which type of declaration to use?
const is not reassigned let is reassigned. Lint rule force const. if let never reassigns, then let.
What is the syntax for writing a template literal?
backtick with ` ${expression}`
What is “string interpolation”?
converted into a string and concatenate. primitives have to string. methods.
What is destructuring, conceptually?
Takes fields out of objects and assigns them into variables.
What is the syntax for Object destructuring?
keyword (key variable) = object variable
What is the syntax for Array destructuring?
[a, b, …rest] = [10, 20, 30, 40, 50];
const [a, b, …rest] = array;
How can you tell the difference between destructuring and creating Object/Array literals?
Left hand side is created and right hand side is evaluation.
What is the syntax for defining an arrow function?
() => {} code
When an arrow function’s body is left without curly braces, what changes in its functionality?
It will simply return the arrow expression
How is the value of this determined within an arrow function?
Go to the lexical, static, parsetime. State of the code or where function is first defined.