ES6 JS Flashcards
When an arrow function’s body is left without curly braces, what changes in its functionality?
without {} the result will be auto returned
with {} you have to add return mannuly
How is the value of this determined within an arrow function?
when the function defined
How is the value of this determined within a normal function?
call time
What is destructuring, conceptually?
Destructuring is a convenient way of extracting multiple values from data stored in (possibly nested) objects and Arrays.
What is a code block? What are some examples of a code block?
Function in if, for, while loop (code with {})
What does block scope mean?
the variable outside the block can be use in block, but the variable in block cannot be use in outside
What is the scope of a variable declared with const or let?
they can’t scope to outside
What is the difference between let and const?
const cannot change (ex: minute per hour, book name…)
let can be change
Why is it possible to .push() a new value into a const variable that points to an Array?
because it’s change the property of object, not abject
How should you decide on which type of declaration to use?
use let when the value probably change in the futures , const for the value that gonna always be the same
What is the syntax for writing a template literal?
xxxx
What is “string interpolation”?
a string contains varible and algorithms.xxxx${xx}xx
What is the syntax for Object destructuring?
const { title, author, libraryID } = book1;
const { title: title2, author: author2, libraryID: libraryID2 } = book2;
What is the syntax for Array destructuring?
const [book3, book4, book5] = library;
How can you tell the difference between destructuring and creating Object/Array literals?
object is {} array is []