JavaScript
JavaScript is the programming language of the web. It enables interactive user interfaces, asynchronous operations, server-side applications, desktop applications, and more.
Learning Path
Fundamentals
- Variables (
var,let,const) - Data Types
- Type Coercion
- Operators
- Scope
- Hoisting
- Functions
- Closures
- Objects
- Arrays
Intermediate
- Event Loop
- Call Stack
- Execution Context
- Prototype Chain
- Classes
- Modules
- Error Handling
- Promises
- Async/Await
Advanced
- Memory Management
- Garbage Collection
- Event Delegation
- Design Patterns
- Performance Optimization
- Functional Programming
- Web Workers
Example: Closures
A closure allows a function to access variables from its outer scope even after the outer function has returned.
function counter() {
let count = 0;
return function () {
count++;
return count;
};
}
const increment = counter();
console.log(increment()); // 1
console.log(increment()); // 2
console.log(increment()); // 3
Why it Works
counter()creates a local variablecount.- The returned function references
count. - JavaScript preserves that variable in memory.
- Each call updates the same variable.
Common Interview Question
What is the difference between let, const and var?
**var**
- Function scoped
- Can be redeclared
- Hoisted and initialized with `undefined`
**let**
- Block scoped
- Cannot be redeclared in same scope
- Exists in Temporal Dead Zone
**const**
- Block scoped
- Cannot be reassigned
- Must be initialized during declaration
Important Notes
Note
Warning
Tip
Master closures, promises, async/await, event loop, and prototype inheritance for senior-level interviews.
Event Loop Overview
Frequently Asked Topics
| Topic | SDE-1 | SDE-2 |
|---|---|---|
| Scope | ✅ | ✅ |
| Closures | ✅ | ✅ |
| Event Loop | ✅ | ✅ |
| Prototypes | ⚠️ | ✅ |
| Memory Management | ❌ | ✅ |
| Design Patterns | ❌ | ✅ |
Recommended Study Order
- Variables and Scope
- Functions
- Closures
- Objects
- Arrays
- Execution Context
- Event Loop
- Promises
- Async/Await
- Prototype Chain
- Memory Management
- Design Patterns
Next Steps
Continue with:
- Fundamentals → Scope & Hoisting
- Fundamentals → Functions
- Fundamentals → Closures
- Browser → Event Loop
- Advanced → Memory Management