How Javascript Works?
JavaScript was created in 1995 by Brendan Eich.
What Can JavaScript Do?
1️⃣ Client Side (In Your Browser)
Client side means inside your browser (Chrome, Edge, Firefox).
JavaScript can:
Example: You like a post on Instagram and the count increases instantly — JavaScript did that.
2️⃣ Server Side (Behind the Scenes)
With tools like Node.js, JavaScript also works on the server.
It can:
Example: When you log in and your data is verified — JavaScript works on the server.
3️⃣ DOM Manipulation (Changing the Page)
DOM means the structure of a web page.
JavaScript can:
Example: Click a button → menu opens → background color changes That instant change is called DOM Manipulation.
How JavaScript Understands Your Code?
You write JavaScript as text, but the computer understands only machine language (1s and 0s).
So JavaScript code goes through three main steps.
Recommended by LinkedIn
Phase 1: Tokenizing (Breaking into Pieces)
First, the browser breaks your code into small parts called tokens.
Example line:
const age = 25;
It becomes:
👉 Think of it like: Breaking a sentence into words and symbols so the computer can read it properly.
Phase 2: Abstract Syntax Tree (AST) – The Blueprint
Now the browser organizes those tokens into a structured form called an AST.
What is an AST?
An AST is like a blueprint or map of your code.
Example analogy:
If you:
The AST cannot be built → Syntax Error occurs.
Phase 3: Compilation (Making It Fast)
Once the AST is ready:
This process is called JIT (Just-In-Time) Compilation.
Meaning: JavaScript is compiled at runtime to make it super fast.
👏🏻👏🏻