ES6 Flashcards
What is the scope of a variable declared with const or let?
block scope
What does block scope mean?
Within the block
What is a code block? What are some examples of a code block?
define within { … }, if, for, while,…
What is the difference between let and const?
let can be reassigned
const cannot be assigned
Why is it possible to .push() a new value into a const variable that points to an Array?
const is mutable ONLY if it’s object
How should you decide on which type of declaration to use?
if you want to reassign value in the future use let, otherwise use const.
What is the syntax for writing a template literal?
backtick () then ${JavaScript Expression}
What is “string interpolation”?
to create strings by doing substitution of placeholders
What is destructuring, conceptually?
convenience way to extract property values of an object (in 1 line)
What is the syntax for Object destructuring?
var/let/const { property1:alias_name = ‘default_value’ , property2, … } = object;
What is the syntax for Array destructuring?
var/let/const [ element1st, element2nd, …. , element#nth ] = array;
How can you tell the difference between destructuring and creating Object/Array literals?
{ } or [ ] is on the left side of = then destructuring
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?
no code block = implicit return (return without return statement)
with { }, will require return keyword to actually return value.
{ } allows for multilines code block
How is the value of this determined within an arrow function?
the value is determine at the definition time, (parent code block)