What is Hoisting? | Most Asked JS Interview Question | The Complete JavaScript Course | Ep.32

preview_player
Показать описание

Hoisting is one of the most underrated yet most asked interview question in javascript. In this video, we'll learn what excatly hoisting is javascript means!
We'll dive deep into the concepts to get a clear idea of temporal dead zone, yes, something we need to cosider. Well, there's one thing I can bet, you'll be so clear that hoisting would be nothing but a cake walk for you.

📖 Chapters
00:00 Hoisting in JavaScript is a commonly asked topic in interviews
02:46 Hoisting in JavaScript moves variable and function declarations to the top of their containing scope.
04:39 Hoisting in JavaScript allows accessing variables before their declaration without errors.
07:15 JavaScript hoists variable and function declarations
09:39 Hoisting in JavaScript allows function and class declarations to be accessed before they are defined.
11:56 Function declaration hoisting in JavaScript
14:19 Hoisting in JavaScript allows function declarations to be moved to the top of the code.
16:48 Hoisting in JavaScript explained
19:27 Understanding function declaration, definition, and hoisting in JavaScript
21:51 Hoisting is a process of moving variable and function declarations to the top in JavaScript
23:49 Understanding function declaration vs. function definition

Have any doubts? Join this Telegram group and ask your question. You can also share the projects that you make in this group.

Social Media

Music by geoffharvey from Pixabay
Рекомендации по теме
Комментарии
Автор

Summary:
What is hosting?
JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables, classes, or imports to the top of their scope, prior to execution of the code.

const and let can not access the value before initialization because they are placed in a temporal dead zone. But in var case, it will give undefined.

But in function, we get values of function because function values are stored during the memory creation phase so we just get access to it.

this much I understood from this video.

*Correct me if I am wrong.

nobody
Автор

Always is used to confuse between undefined and not defined. Got it clear.
* undefined is not an error, it is a datatype - thinks to remember for beginners

GauthamHC
Автор

Hoisting:
Hoisting is a JavaScript behavior where variables and functions are moved to the top of their scope, regardless of their actual declaration position.

Variable Hoisting
var is hoisted with undefined.
let & const are hoisted but not initialized (Temporal Dead Zone).
Example:
console.log(x); // undefined
var x = 10;

// Equivalent to:
var x;
console.log(x); // undefined
x = 10;


Function Hoisting
Function declarations are fully hoisted.
Function expressions are partially hoisted (variable is hoisted, but not the function).

vishalmishrausername
Автор

Best way of explaning thanks
saw so many videos on this topic all are saying hoisting is to move the declarations to the top but you explained in detail how javascript hoisting is working in background thanks for making this video😊

SahilRajput-ions
Автор

00:02 Hoisting in JavaScript is a commonly asked topic in interviews
02:46 Hoisting in JavaScript moves variable and function declarations to the top of their containing scope.
04:39 Hoisting in JavaScript allows accessing variables before their declaration without errors.
07:15 JavaScript hoists variable and function declarations
09:39 Hoisting in JavaScript allows function and class declarations to be accessed before they are defined.
11:56 Function declaration hoisting in JavaScript
14:19 Hoisting in JavaScript allows function declarations to be moved to the top of the code.
16:48 Hoisting in JavaScript explained
19:27 Understanding function declaration, definition, and hoisting in JavaScript
21:51 Hoisting is a process of moving variable and function declarations to the top in JavaScript
23:49 Understanding function declaration vs. function definition
Crafted by Merlin AI.

AdarshSingh-hmss
Автор

I have seen a first time a youtuber who always reply (or give heart) on the viewer's comment.. I really appreciate it bhaiya..

mdfurquanalam
Автор

Very nicely explained! My memory creation phase is running at full speed now!

zuhairrehman
Автор

I started this playlist This is day 3 I know basics of javascript so I will binge watch basic part and if I found any topic which I don't know then I will try that topic

samith-ny
Автор

i like i like this video also now total like is =70....this guy deserve more like and subscriber...

Sumeet_Katkade
Автор

best video of hoisting ever i have watched ❤❤❤

CreateReacter
Автор

Day 11: video 32 completed ....thank you sir making such great video 😊

Collecting_one_piece_fan
Автор

🎉🎉🎉 bhot Hi Simple Way me Explain kardiya ❤❤❤ 10 out of 100 💯💯💯💯😁

ParvezKhan-epzg
Автор

awesome sir, ky bolu sir sabd nhi hai bolne ke liya, aap itna aacha padte hai, love u

SUJAL-FACT-YT
Автор

I felt it, when you said, @24:05 anonymous ki spelling bahut khatarnak hoti h(CBSE wale is pain ko kabhi nhi samajh sakte.)

abhishekkumar-ubln
Автор

Sir, function expression m jab uss function ko call krte h tab uski memory allocation phase nhi hoti kya..kyuki debugger lga n k baad jab function call krte h toh wo variable tab tak nhi dikhata jab tak usme variable assign na ho..esa kyu hota h?

simransah
Автор

Hi sir,
You just explained everything in detailed really like how you explain.
Just had one doubt
As we know var, let, const all are hoisted but let and const go yo temporal dead zone and we cannot access it until it is initialized.

Now just will give 3 examples

Eg 1

Let a = 0
Console.log(a)
Output = 0

Eg 2

Console.log(a)
Let a= 3:
Output : cannot access a before initialization.


Eg 3

Let a;
Console.log(a)
a=2;
Output : undefined

I understood 2nd but 3rd as during memory allocation phase a will be undefined and as its declare using let it will go to temporal dead zone and we cannot accept until it is assigned with value, so in this case how we are getting undefined.

vikasmv
Автор

Very good resoucre you are, i wonder why this video has only 2k view

akshayiitk
Автор

anonymous ki spelling bahut khatarnaak hoti hai 24:00, waah bhaiya maje aate hai video dekhte samay, baaki clear cut this topic...🤣🤣😂😂

deepend
Автор

Hoisting mein var aur functions declaration upar shift hone jaisa appear krte hain pr in reality woh upar shift nhi hote hain. Hoisting mtlb variable can be accessed before it is declared and initialized.

adityasinghh
Автор

I added this code
debugger
console.log(a)
const a= 35

In Script showing output as
a: <value unavailable>

But in video it is showing as undefined

Can you explain why this difference?

lakshmansibbala