reading-notes

this repo will contain my reading during the course .

View project on GitHub

Review, Research, and Discussion

Describe what Array.map() does :

The map() method creates a new array populated with the results of calling a provided function on every element in the calling array so the map() method creates a new array with the results of calling a function for every array element. The map() method calls the provided function once for each element in an array, in order. map() does not execute the function for empty elements. map() does not

Describe what Array.reduce() does :

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value so the reduce() method executes a reducer function for each value of an array. reduce() returns a single value which is the function’s accumulated result. reduce() does not execute the function for empty array elements. reduce() does not change the original array.

Provide code snippets showing how to use superagent() to fetch data from a URL and log the result

  • With normal Promise .then() syntax:

SuperAgent is a small HTTP request library that may be used to make AJAX requests in Node. js and browsers

superagent.get(url).then(reult=>{consle.log(result)}.catch(err=>{consle.log(err)}

  • with async / await syntax:

let getData=async()=>{ let data=await superagent.get(url)consle.log(data.body)}; grtData()

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

promise is an object that may produce a single value some time in the future : either a resolved value, or a reason that it’s not resolved (e.g., a network error occurred). A promise may be in one of 3 possible states: fulfilled, rejected, or pending so Promises are used to handle asynchronous operations in JavaScript. They are easy to manage when dealing with multiple asynchronous operations where callbacks can create callback hell leading to unmanageable code. … Multiple callback functions would create callback hell that leads to unmanageable cod

img

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

Simply taking a callback doesn’t make a function asynchronous. There are many examples of functions that take a function argument but are not asynchronous. … It iterates over each item and calls the function once per item, he callback will be synchronous when the higher order function which calls it is calling it synchronously. Inversely if it is called within the context of the execution branch of an asynchronous operation it will be asynchronous