reading-notes
Project maintained by mr-atta
Hosted on GitHub Pages — Theme by mattgraham
Node Ecosystem, TDD, CI/CD
Array.map()
- .map() is a method used with arrays. it create new array filled from the result .
- .map() used the original array to run the code over each element(we can use the element or updated) of the original array to create a new one, as we say.
- Must use return in .maP() code .
- The new array should be the same length as the original.
Parameters :
- callbackFn
- element
- index (Optional)
- array (Optional)
- thisArg (Optional)
LIKE
let numbers = [1, 4, 9]
let roots = numbers.map(function(num) {
` return Math.sqrt(num)
})`
Array.reduce()
- .reduce is a method used with arrays. don’t affect the original array.
- .reduce used the original array to run the code over each element(find the summation to the array) of the original array.
Parameters :
- callbackFn
- accumulator
-
currentValue
- index (Optional)
- array (Optional)
- initialValue (Optional)
LIKE
[0, 1, 2, 3, 4].reduce((accumulator, currentValue, currentIndex, array) => {
return accumulator + currentValue
}, 10)
superagent()
promises
- JS does the code synchronously (step by step), if there is a block that will take time the JS will not do it in order but will promise it back when it is finished.
Are all callback functions considered to be Asynchronous? Why or Why Not?
- not all of them, just when we use (.then or async / await)
mdn
code