Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 451 Bytes

File metadata and controls

23 lines (18 loc) · 451 Bytes

Async JS

  • Event Loop
  • callbacks
function doLongRunningThingAndGiveAnswerAfter(someFunctionToCallLater) {
  setTimeout(function () {
    someFunctionToCallLater(42);
  }, 2000);
}

function someOtherFunctionThatGetsTheAnswer(answer) {
  // this will log after 2 seconds...
  console.log(answer);
}

doLongRunningThingAndGiveAnswerAfter(someOtherFunctionThatGetsTheAnswer);
  • Promises
    • async / await
  • API Requests, JSON, fetch, cors