Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 2.43 KB

File metadata and controls

38 lines (24 loc) · 2.43 KB

Review, Research, and Discussion

  1. Describe (in plain English) what Array.map() does

Array.Map() is used to create a new array by calling a function on each element of the passed array.


  1. Describe (in plain English) what Array.reduce() does

It turns out this function’s versatility and power come from its lack of specialization. Like Array.map, Array.reduce iterates over the array and invokes the callback on each element. The difference is that instead of returning an array of equal size containing whatever was returned by the callback in each element, it returns whatever the final invocation of the callback returns


  1. how to use superagent() to fetch data from a URL

SuperAgent is light-weight progressive ajax API crafted for flexibility, readability, and a low learning curve after being frustrated with many of the existing request APIs. It also works with Node.js!

request .post('/api/pet') .send({ name: 'Manny', species: 'cat' }) .set('X-API-Key', 'foobar') .set('Accept', 'application/json') .then(res => { alert('yay got ' + JSON.stringify(res.body)); });


  • Explain promises as though you were mentoring a Code 301 level student

    A Promise object is simply a wrapper around a value that may or may not be known when the object is instantiated and provides a method for handling the value after it is known (also known as resolved) or is unavailable for a failure reason (we’ll refer to this as rejected ).

  • Are all callback functions considered to be Asynchronous? Why or Why Not?

    Callbacks that you call yourself are regular function calls, which are always synchronous. Certain native APIs (eg, AJAX, geolocation, Node. js disk or network APIs) are asynchronous and will execute their callbacks later in the event loop

    The callback is a function that's accepted as an argument and executed by another function (the higher-order function). There are 2 kinds of callback functions: synchronous and asynchronous. The synchronous callbacks are executed at the same time as the higher-order function that uses the callback

    Every asynchronous function takes a function argument, but not every function that does so is asynchronous. It matters how the argument is used inside the function.