# 🕸 Asynchronous Programming

2 min read, 211 words asynchonouscallbackpromiseasyncawait

synchronous vs asynchronous code execution order

blocking va non blocking code

# ⛱ Approach

  1. Callbacks
    1. callback hell (opens new window)
  2. Promises
  3. Async/await
Built to be used with web browser. Why?[1]

Eliminate browser freezes[2].

Because users can interact with webpage TTI (opens new window) only after HTML and CSS are loaded and parsed. JS execution could be deffered. Asynchronocity helps browsers to be more responsive towards user interactions.

  • Normally execution is synchronous, function waits for the response of the called function before proceeding with further execution
  • Blocking code | Non-blocking code
When do we generally use asynchronous programming[1:1]? aka non-blocking programming?
When we have to implement features like.
  1. timer functions
  2. listening to network call, database query calls etc
  3. reading or writing, generally to/from and IO device
  4. subscribing to an event, topic in pub/sub
  5. EventListners

# Async - await

Arrow function

Arrow functions => have an implicit return feature

  • are not hoisted
  • always anonymous, lambda functions

# đŸĢ References

_TTI (opens new window): Time to Interactive performance metrics _[HTML]: Hypertext Markup Language, current spec 5 _[CSS]: Cascading style Sheets, current spec 3 _[JS]: Ecmascript Standard

Subscribe to our Newsletter

If you like my work and think it was helpful kindly support my work


Buy Me A Coffee

  1. https://en.wikipedia.org/wiki/Asynchrony_(computer_programming) (opens new window) â†Šī¸Ž â†Šī¸Ž

  2. https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Concepts (opens new window) â†Šī¸Ž