Section 6: Async Foundations Flashcards
Define a “Callback Function”
A function that is passed into another function as a parameter, then invoked by that other function.
Name the parameters of the ‘forEach’ method
forEach(array, callback)
someArray.forEach(function(element, index, array) {
console.log(item);
});
Name the parameters of the callback function inside the forEach method.
someArray.forEach(function(element, index, array) {
console.log(element);
});
What does the the ‘findIndex’ method do?
It returns the index of the first element in the array for which the callback returns a truthy value. ‘-1’ is returned if the callback never returns a truthy value.
Define how ‘the Stack’ is set up and how it works.
- An ordered set of stack frames
- Most recently invoked function is on the top of the stack
- The bottom of the stack is the first function invoked
- The stack is processed from top to bottom.
Define ‘the Heap’
- An area in memory where your data is stored