Javascript - Asynchrony

1 - About

Asynchronous in javascript.

Asynchrony is not only critical to the performance of our applications, it’s increasingly becoming the critical factor in writability and maintainability.

Method:

Fetch operations are asynchronous by nature and returns generally a promise. See Browser - Ajax (Asynchronous JavaScript And XML).

3 - Method

3.1 - Callback

callbacks is the primary method of enabling asynchrony.

Callback pyramid of doom


// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
doSomething(function(result) {
  doSomethingElse(result, function(newResult) {
    doThirdThing(newResult, function(finalResult) {
      console.log('Got the final result: ' + finalResult);
    }, failureCallback);
  }, failureCallback);
}, failureCallback);

getData( a => {
     getMoreData(a, b => {
         getMoreData(b, c => {
             getMoreData(c, d => {
                 getMoreData(d, e => {
                     console.log(e);
                 }
             }
         }
     }
}


3.2 - Promise

4 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap