Synchronous,Asynchronous in JavaScript

What is Synchronous?

In synchronous,each line of code executes line by line.
that means,each line of code waits for the previous one to execute

Example:

console.log(“Hi”)
console.log(“Welcome”)

Output
Hi
Welcome

What is Asynchronous?

In a…


This content originally appeared on DEV Community and was authored by Kavya S

What is Synchronous?

In synchronous,each line of code executes line by line.
that means,each line of code waits for the previous one to execute

Example:

console.log("Hi")
console.log("Welcome")

Output
Hi
Welcome

What is Asynchronous?

  • In asynchronous,a task can be initiated and while waiting for it to complete, other task can be proceed.
  • It improves performance

Example:

console.log("Task1")
setTimeOut(()=>{
console.log("Task2")
},2000);
console.log("Task3")

Output
Task1
Task3
Task2


This content originally appeared on DEV Community and was authored by Kavya S


Print Share Comment Cite Upload Translate Updates
APA

Kavya S | Sciencx (2025-09-11T01:14:07+00:00) Synchronous,Asynchronous in JavaScript. Retrieved from https://www.scien.cx/2025/09/11/synchronousasynchronous-in-javascript/

MLA
" » Synchronous,Asynchronous in JavaScript." Kavya S | Sciencx - Thursday September 11, 2025, https://www.scien.cx/2025/09/11/synchronousasynchronous-in-javascript/
HARVARD
Kavya S | Sciencx Thursday September 11, 2025 » Synchronous,Asynchronous in JavaScript., viewed ,<https://www.scien.cx/2025/09/11/synchronousasynchronous-in-javascript/>
VANCOUVER
Kavya S | Sciencx - » Synchronous,Asynchronous in JavaScript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/09/11/synchronousasynchronous-in-javascript/
CHICAGO
" » Synchronous,Asynchronous in JavaScript." Kavya S | Sciencx - Accessed . https://www.scien.cx/2025/09/11/synchronousasynchronous-in-javascript/
IEEE
" » Synchronous,Asynchronous in JavaScript." Kavya S | Sciencx [Online]. Available: https://www.scien.cx/2025/09/11/synchronousasynchronous-in-javascript/. [Accessed: ]
rf:citation
» Synchronous,Asynchronous in JavaScript | Kavya S | Sciencx | https://www.scien.cx/2025/09/11/synchronousasynchronous-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.