Chapter 3 Flashcards
(19 cards)
what are the two roles of the … operator?
rest and spread
what are the two options in which the spread operator can be used?
in an array or as an argument function call
const test = […testArray];
or
testFunction(…test)
iterable
a value that can be iterated over
what is the iterator-consumption protocol used for?
consuming iterables
how does the iterator-consumption protocol work?
automatically creates an iterator instance from an iterable, and consumes just that iterator instance to its completion. This means a single iterable could be consumed more than once; each time, a new iterator instance would be created and used.
what is an iterator protocol?
a standard way to produce a sequence of values (either finite or infinite), and potentially a return value when all values have been generated.
how does iteration work on Maps?
it iterates over its entries not its values, and each entry has a value and a key

how can we get the index and value in an array iteration?
for (let [idx,val] of arr.entries()) {…}

default iteration
each type of iteration has a main or default iteration method, but also exposes other methods if different data needs to be accessed
in js what are the main iterator forms that are usually available on any given built-in iterables?
- keys-only (keys())
- values-only (values())
- entries (entries())
Closure
is when a function remembers and continues to access variables from outside its scope, even when the function is executed in a different scope
what is the difference between scope and execution context?
Scope is static and is comprised of the variables available at the time and location that you defined the function
The execution context is dynamic and dependent on how it is called
what does the call method do?
binds the execution context the specified object
someObject.call(someFunction)
what is another word of/way we reference this?
execution context
prototype chain
A series of objects linked together via prototypes
What is the purpose of prototype linkage?
accesses against B for properties/methods that B does not have, are delegated to A to handle.
ie. Delegation of property/method access allows two (or more!) objects to cooperate with each other to perform a task.
How can you define an object prototype linkage?
you can create the object using the Object.create(..) utility
let otherHomework = Object.create(homework);
what does Object.create(null) do?
creates an object that is not prototype linked anywhere, so it’s purely just a standalone object