# Execution Context & Call Stack

### **How JavaScript Code Executes**

JavaScript uses a **single-threaded** model with an **event loop**. It executes code in two phases:

1. **Creation Phase**: Memory allocation for variables and functions.
    
2. **Execution Phase**: Runs the code line by line.
    

### **Example:**

```javascript
jsCopyEditconsole.log("Start");

function greet() {
    console.log("Hello!");
}

greet();

console.log("End");
```

✅ **Execution Order:**

1. `"Start"` prints.
    
2. `greet()` is called, and `"Hello!"` prints.
    
3. `"End"` prints.
    

🛠 **Call Stack Visualization:**

* `console.log("Start")` → Pushed & executed.
    
* `greet()` → Pushed, executes `console.log("Hello!")`, then popped.
    
* `console.log("End")` → Pushed & executed.
