https://github.com/mudasirrr/synchronous-vs-asynchronous
synchronous code is executed in sequence – each statement waits for the previous statement to finish before executing. Asynchronous code doesn't have to wait – your program can continue to run. You do this to keep your site or app responsive, reducing waiting time for the user.
https://github.com/mudasirrr/synchronous-vs-asynchronous
Last synced: 4 months ago
JSON representation
synchronous code is executed in sequence – each statement waits for the previous statement to finish before executing. Asynchronous code doesn't have to wait – your program can continue to run. You do this to keep your site or app responsive, reducing waiting time for the user.
- Host: GitHub
- URL: https://github.com/mudasirrr/synchronous-vs-asynchronous
- Owner: Mudasirrr
- Created: 2020-06-27T22:21:45.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-27T22:28:14.000Z (about 5 years ago)
- Last Synced: 2025-01-16T18:27:39.616Z (6 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Synchronous-vs-Asynchronous
# Introduction
In programming, synchronous operations block instructions until the task is completed, while asynchronous operations can execute without blocking other operations. Asynchronous operations are generally completed by firing an event or by calling a provided callback function.# Breaking Down JavaScript
Javascript has a:## Callstack
## WebAPI
## Event Loop
## Callback Queue
## The Callstack is the immediate work your program will do.# Synchronous Operations
Synchronous Operations that run block the next operation until it completes. Blocking operations may not always seem like an issue because computers are fast.
Making requests to your own services like a database can have the same effect. A common webpage will have many requests to make under unique circumstances, and as a developer, you'll want those requests to start as soon as possible but still allow the rest of the page to load what it can to enable the requests.
This is when asynchronous operations become powerful.# Asynchronous Operations
Asynchronous Operations happen independently from the main program flow. A common use for asynchronous code is querying a database and using the result. Passing in a callback is a way to interact with the response or error.