
Web Development - HTML, CSS & JavaScript
@javascript_courses
Learn to code and become a Web Developer with HTML, CSS, JavaScript , Reactjs, Wordpress, PHP, Mern & Nodejs knowledge
Open in Telegram
Channel
Subscribers
684
Current member count
Type
Channel
Telegram channel
Global Rank
#1,093
Directory ranking
Live Channel Feed
View on Telegram
š§š¢š£ šš„šš šš¢šØš„š¦šš¦ š§š¢ šš¢š¢š¦š§ š¬š¢šØš„ š¦ššššš¦ šš” š®š¬š®š²!
Explore FREE online learning resources to develop in-demand skills and improve your career opportunities!
š Why Explore These Courses?
ā
Learn valuable professional skills
ā
Improve your resume
ā
Build practical knowledge
ā
Learn at your own pace
šš
š½š¹š¼šæš² šš„šš šš¼ššæšš²š šš²šæš²š
https://pdlink.in/3VBdt6V
š” Learn New Skills ā Build Confidence ā Unlock Career Opportunities!
Oct 13, 04:37 AM
585
doesn't work because "a" is block-scoped.
ā 1ļøā£5ļøā£ What Is an Execution Context?
When JavaScript runs code, it creates an execution context.
An execution context is the environment in which JavaScript evaluates and executes code.
At a high level, there are different kinds of execution contexts.
The most important ones initially are:
⢠Global Execution Context: Created when your JavaScript program begins executing.
⢠Function Execution Context: Created whenever a function is called.
For example:
const name = "Rahul";
function greet() {
const message = "Hello";
console.log(message);
}
greet();
Conceptually:
Global Execution Context
ā
greet() called
ā
Function Execution Context
1ļøā£6ļøā£ Creation Phase and Execution Phase
A simplified mental model is that JavaScript prepares an execution context before executing its statements.
During setup, JavaScript determines things such as:
⢠Variable bindings
⢠Function declarations
⢠Lexical environments
Then JavaScript executes the code.
For example:
var age = 25;
function greet() {
console.log("Hello");
}
During the setup process, JavaScript prepares the relevant bindings.
Then execution proceeds through the statements.
This helps explain why function declarations and "var" behave differently from "let" and "const".
1ļøā£7ļøā£ Execution Context Stack
JavaScript uses a call stack to keep track of active function execution.
Example:
function first() {
second();
}
function second() {
third();
}
function third() {
console.log("Hello");
}
first();
The execution roughly looks like:
third()
ā
second()
ā
first()
ā
Global
When "third()" finishes:
third() removed
Then:
second() finishes
Then:
first() finishes
Eventually the stack becomes empty.
ā 1ļøā£8ļøā£ Call Stack
The call stack follows:
LIFO (Last In, First Out)
For:
function first() {
second();
}
function second() {
console.log("Hello");
}
first();
The stack conceptually becomes:
1. Global
2. first()
3. second()
Then:
second() removed
first() removed
Global continues
Understanding the call stack becomes very important when we later study:
⢠Callbacks
⢠Asynchronous JavaScript
⢠Promises
⢠Event loop
⢠Stack overflow
ā 1ļøā£9ļøā£ Scope vs Execution Context
These concepts are related but not identical.
⢠Scope answers: "Where can this variable be accessed?"
⢠Execution context answers more broadly: "What environment is JavaScript using while executing this code?"
For example:
const name = "Rahul";
function greet() {
const message = "Hello";
console.log(name);
console.log(message);
}
Scope determines which variables are accessible.
Execution context represents the environment created when "greet()" is actually executed.
ā 2ļøā£0ļøā£ Closures Preview
Closures are built on lexical scope.
Consider:
function createCounter() {
let count = 0;
return function () {
count++;
return count;
};
}
const counter = createCounter();
console.log(counter());
console.log(counter());
console.log(counter());
Output:
1
2
3
The returned function continues to access "count" even after "createCounter()" has finished executing.
š Double Tap ā¤ļø For More
Oct 12, 06:05 PM
717
When "inner()" looks for:
name
it finds it in its own scope.
For:
city
JavaScript looks in the outer scope.
For:
country
it goes one level further outward.
Conceptually:
inner scope
ā
outer scope
ā
global/module scope
This is the scope chain.
8ļøā£ What Is Hoisting?
Hoisting describes how JavaScript's execution process makes certain declarations available before their position in the source code is reached.
But different declarations behave differently.
This is why you should avoid thinking of hoisting as simply:
"JavaScript moves all code to the top."
That's not an accurate mental model.
9ļøā£ Function Declaration Hoisting
Function declarations can be called before their declaration in the same scope.
greet();
function greet() {
console.log("Hello");
}
Output:
Hello
The function declaration is available when execution begins.
š "var" Hoisting
Consider:
console.log(age);
var age = 25;
The result is:
undefined
Conceptually, you can think of the declaration being initialized early:
var age;
console.log(age);
age = 25;
The important point is:
var declaration ā initialized as undefined
before normal execution reaches the assignment.
1ļøā£1ļøā£ "let" and "const" Hoisting
Now consider:
console.log(age);
let age = 25;
This produces a ReferenceError.
The same applies to:
console.log(age);
const age = 25;
Why?
"let" and "const" declarations are created during the setup phase, but they aren't initialized until execution reaches their declaration.
The period between entering the scope and initialization is called the:
Temporal Dead Zone (TDZ)
1ļøā£2ļøā£ Temporal Dead Zone
Example:
{
console.log(name);
let name = "Rahul";
}
The variable "name" exists in the scope, but accessing it before initialization causes an error.
Conceptually:
Block begins
ā
name exists but is uninitialized
ā
Temporal Dead Zone
ā
let name = "Rahul"
ā
name becomes initialized
So:
console.log(name);
let name = "Rahul";
is not equivalent to using "var".
1ļøā£3ļøā£ Why "let" and "const" Are Safer
Compare:
console.log(value);
var value = 10;
Output:
undefined
versus:
console.log(value);
let value = 10;
Error:
ReferenceError
The error makes the problem much easier to detect instead of silently giving you undefined.
1ļøā£4ļøā£ Function Scope vs Block Scope Example
Consider:
function test() {
if (true) {
let a = 10;
var b = 20;
}
console.log(b);
}
test();
This works because "b" is function-scoped.
But:
function test() {
if (true) {
let a = 10;
}
console.log(a);
}
Oct 12, 06:05 PM
465
š» JavaScript Roadmap 2026 ā Part 9
š” Scope, Hoisting & Execution Context
Now we're moving from basic JavaScript syntax into concepts that explain how JavaScript actually executes your code.
These concepts are extremely important because they explain things like:
⢠Why some variables are accessible in certain places but not others
⢠Why functions can sometimes be called before they are written
⢠Why "let" and "const" behave differently from "var"
⢠How JavaScript manages function calls
⢠How nested functions access variables from outer functions
1ļøā£ What Is Scope?
Scope determines where a variable can be accessed in your program.
For example:
let name = "Rahul";
console.log(name);
The variable "name" is accessible here because it was declared in the outer scope.
But:
function greet() {
let message = "Hello";
console.log(message);
}
greet();
"message" is available inside "greet()".
Trying to access it outside:
console.log(message);
causes an error because "message" belongs to the function's local scope.
2ļøā£ Global Scope
A variable declared outside functions and blocks is generally in the global/module scope depending on how your JavaScript is executed.
Example:
const appName = "My App";
function showAppName() {
console.log(appName);
}
showAppName();
Output:
My App
The function can access "appName" because the variable exists in an outer scope.
3ļøā£ Function Scope
Variables declared inside a function are accessible within that function.
function calculate() {
const price = 1000;
console.log(price);
}
calculate();
This works.
But:
console.log(price);
doesn't work because "price" exists only inside "calculate()".
4ļøā£ Block Scope
A block is code surrounded by "{}".
For example:
if (true) {
let message = "Hello";
console.log(message);
}
"message" exists inside that block.
But:
console.log(message);
causes an error.
Variables declared using:
⢠let
⢠const
are block-scoped.
5ļøā£ "var" and Block Scope
This is one reason "var" can cause confusing behavior.
if (true) {
var message = "Hello";
}
console.log(message);
This can print:
Hello
because "var" is not block-scoped.
Compare:
if (true) {
let message = "Hello";
}
console.log(message);
This causes an error because "let" is block-scoped.
Remember:
⢠var ā function-scoped
⢠let ā block-scoped
⢠const ā block-scoped
6ļøā£ Lexical Scope
JavaScript uses lexical scoping.
This means the scope of a variable is determined by where the code is written, not where the function is eventually called.
Example:
const name = "Rahul";
function outer() {
function inner() {
console.log(name);
}
inner();
}
outer();
"inner()" can access "name" because "name" exists in an outer lexical scope.
7ļøā£ Scope Chain
What happens if JavaScript can't find a variable in the current scope?
It looks outward.
Example:
const country = "India";
function outer() {
const city = "Pune";
function inner() {
const name = "Rahul";
console.log(name);
console.log(city);
console.log(country);
}
inner();
}
outer();
Oct 12, 06:05 PM
453

š šŖšµš¶š°šµ š§š²š°šµ š¦šøš¶š¹š¹ šŖš¶š¹š¹ š¬š¼š š š®ššš²šæ š¶š» š®š¬š®š²?
Want to build apps, uncover insights, or create AI solutions? Explore certification courses that match your career goals! šÆ
š» ššš¹š¹ š¦šš®š°šø šš²šš²š¹š¼š½šŗš²š»š
š https://pdlink.in/3SuUeuD
š šš®šš® šš»š®š¹ššš¶š°š
š https://pdlink.in/45vk5ph
š«šš šš»š“š¶š»š²š²šæš¶š»š“
š https://pdlink.in/4fWJVID
š„ Choose your path, sharpen your skills, and take the next step towards your tech career!
š Save this post & share it with a friend planning to upskill.
Oct 12, 10:24 AM
768
Safety & Compliance Disclaimer
TelePilot Pro is not affiliated with Telegram. Listings are based on publicly available community information. We index public groups, channels, and bots only. No private user data, phone numbers, or locked session files are stored or displayed.
TelePilot Pro Automation
Scale Your Telegram Community Faster
Join thousands of marketers using TelePilot Pro to bulk message, scrape targeted members, and manage groups on autopilot. Outperform competitors with our 40+ professional automation tools.