This repository contains daily learning notes, summaries, and practice related to the core fundamentals of JavaScript.
It covers essential building blocks like execution context, call stack, scoping, hoisting, closures, function types, and the event loop — concepts every serious JavaScript developer must understand.
- Daily revision and hands-on practice
- In-depth explanations of how JavaScript actually works
- A growing reference of my personal JavaScript understanding
- Code Execution
JavaScript code runs in two phases — memory creation and execution. - Call Stack
Manages function calls in a Last-In-First-Out (LIFO) manner. undefined
vsis not defined
undefined
: declared but not assigned.is not defined
: variable is never declared.
- Window Object
In browsers,window
is the global object that holds global variables and functions. - Variable Scoping
Scope determines where a variable can be accessed — function or block level.
- Lexical Environment
The environment where variables and functions are physically written, which determines scope access. - Scope Chaining
If a variable is not found in the current scope, JavaScript looks up the outer scopes. - Hoisting
Variables and functions are moved to the top of their scope during the memory phase. - Temporal Dead Zone (TDZ)
The period between entering a block and variable initialization wherelet
/const
cannot be accessed.
- Closure
A closure gives you access to an outer function’s scope from an inner function. Closures are created every time a function is created, at function creation time. Useful in data encapsulation, function factories, and maintaining state in async code.
- Function Statement / Declaration
Declared with thefunction
keyword and hoisted completely. - Function Expression
Assigned to a variable. Not hoisted like declarations. - Anonymous Function
A function without a name, often used in expressions or as arguments. - Function Call & Invocation
Executing the function using parentheses()
. - IIFE (Immediately Invoked Function Expression)
Runs immediately after being defined:(function() { console.log("IIFE runs!"); })();
- First-Class Functions
Functions in JavaScript can be passed as values, returned from other functions, and stored in variables. - Arrow Functions
Shorter syntax:const add = (a, b) => a + b;
Arrow functions do not have their ownthis
,arguments
, orsuper
. - Function with Arguments & Parameters
Parameters are variables listed as function inputs. Arguments are the actual values passed. - Default Parameters
Allow initializing parameters with default values:function greet(name = "Guest") { console.log("Hello, " + name); }
- Named Function Expression
Function expressions with a name, useful for recursion or debugging. - Callback Function
A function passed into another function as an argument, called later.
- Event Loop (In-Depth)
JavaScript is single-threaded but handles async tasks using the following components:- Call Stack
- Web APIs (Browser)
- Callback Queue / Task Queue
- Microtask Queue
- Event Loop moves tasks from queues to the call stack when it's empty