Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for #
Anandteerth Onkar
Anandteerth Onkar

Posted on

     

#"/t/javascript">#javascript#callbacks#promises#asyncawait

Understanding the Synchronous and Asynchronous operations:

In synchronous operations, operation are performed one at a time. The next operation is unblocked only when the ongoing operation is completed.
Simple words, you need to wait for a operation in progress to finish, in order to start the next one in the queue.

In asynchronous operations, the next operation can be started before the previous one finishes.
Asynchronous programming allows to handling of multiple requests simultaneously, thereby allowing to accomplish more tasks within shorter time span.

So what is JavaScript?

At its core, JavaScript is by default Synchronous in nature.

Let's break it down:
It is Synchronous because it is Single-threaded. In single-thread one operation is executed at a time.
It blocks other operations in queue, as they need to wait until the previous operation has completed execution.

In nutshell:
In JavaScript, only one operation will be executed at a time and the successive operations in stack need to wait until the ongoing operation is completed.

Question: If JavaScript is Synchronous in nature, why on this earth Asynchronous JavaScript term so popular amongst JavaScript developers?

Answer: The developers manipulate JavaScript to behave Asynchronously. To make this manipulation, there are 3 techniques:

  1. Callback function
  2. Promises
  3. Async/Await.

Resources I recommend to understand these asynchronous techniques:

Callbacks:
Watch this awesome video byPhilip Roberts while referring to hisDemo website

Callback Hell: Callback Hell is a Nightmare. Refer this if you want to dig deeper into callbacks

Promises:
Video byCodevolution

Async/Await:
Best article on this topic byMostafa Gaafar

All 3 techniques in one video bycodeSTACKr


I will be creating articles on each of these topics. Need feedback from bloggers & readers of dev community, that will help me to improve my work.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Anandteerth Onkar
Test Engineer
  • Location
    Ireland
  • Joined

More fromAnandteerth Onkar

Cypress: Complete Setup Guide
#node#cypress#javascript#testing
DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp