---
title: "Discussion on \"Synchronous vs Asynchronous JavaScript: Why Your Code Doesn’t Always Run in Order\" | Hashnode"
description: "Discussion on \"Synchronous vs Asynchronous JavaScript: Why Your Code Doesn’t Always Run in Order\". “Why didn’t my code run line by line?”\nYou write this:\nconsole.log(\"Start\");\n\nsetTimeout(() => {\n  console.log(\"Inside timeout\");\n}, 2000);\n\nconsole.log(\"End\");\n\nAnd expect:\nStart  \n(wait 2 seconds)"
url: "https://hashnode.com/posts/synchronous-vs-asynchronous-javascript-why-your-code-doesn-t-always-run-in-order/69de725091716f3cfb586c39"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Synchronous vs Asynchronous JavaScript: Why Your Code Doesn’t Always Run in Order](https://synchronousvsasynchronousjavascriptineasyway.hashnode.dev/synchronous-vs-asynchronous-javascript-why-your-code-doesn-t-always-run-in-order?utm_source=hashnode&utm_medium=feed)

“Why didn’t my code run line by line?” You write this: console.log("Start"); setTimeout(() => { console.log("Inside timeout"); }, 2000); console.log("End"); And expect: Start (wait 2 seconds)

Apr 14 · 4 min read · synchronousvsasynchronousjavascriptineasyway.hashnode.dev  
Read the article

-   [#chaicode](https://hashnode.com/tag/chaicode)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#javascript-synchronous-asynchronous-eventloop-programming-webdevelopment-javascriptbasics](https://hashnode.com/tag/javascript-synchronous-asynchronous-eventloop-programming-webdevelopment-javascriptbasics)

## Written by

[Adarsh Pandey](https://hashnode.com/@Adarshbytes)

@Adarshbytes

  
[View profile](https://hashnode.com/@Adarshbytes)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
