PROMISES, ASYNC, AWAIT, IN JAVASCRIPT

Asynchronous Methods

  • Callback
  • Promises with no async/await [ES6]
  • Promises with async/await [ES8]

Callback

Promise

Creating and Using A Promise

What is the difference between Callbacks and Promises?

The main difference between Callback Functions and Promises is that we attach a callback to a Promise rather than passing it. So we still use callback functions with Promises, but in a different way (chaining).

Using async await syntax

async…await Advantage

  • The resulting code is much cleaner
  • Error handling is much simpler and it relies on try/catch just like in any other synchronous code.
  • Debugging is much simpler. Setting a breakpoint inside a .then block will not move to the next .then because it only steps through synchronous code. But, you can step through await calls as if they were synchronous calls.

Javascript Atolyesi

By mervekara

Javascript Atolyesi

  • 37