How JavaScript Code is executed? ❤️& Call Stack | Namaste JavaScript Ep. 2

preview_player
Показать описание
Understand how the code is executed in JavaScript. How an Execution Context is created and how the Call Stack works. Behind the scenes, there are a lot of things happening in JS Engine when the code is executed. All core fundamentals are covered in this video with examples.

With this code example in the video, you'll understand how things are working under the hood of javascript when code is executed. You'll get to know what exactly happens when you invoke a function in JavaScript. This js tutorial covers various underlying core fundamentals in depth.

Topics Covered:
00:00 - What happens when you run JavaScript Code?
00:32 - Code Example for Execution Context Creation
01:03 - Global Execution Context Creation
01:20 - Memory Allocation Phase & Code Execution Phase
05:56 - Function Invocation and Execution Context Creation
11:15 - What happens while executing return statement
16:35 - Recap of Code Execution synchronously
19:26 - Call Stack in JavaScript
22:21 - Other names of the Call Stack in JS
23:10 - Thank you for watching Namaste JavaScript 🙏

Support this video series, NOT BY MONEY, but by sharing it with your friends. 🙏
I'll give my best to come up with great content and everything absolutely for free on YouTube. 😊

If you are active on Social Media,
please give a shoutout to Namaste JavaScript and help me reach more people. 🙏

Cheers,
Akshay Saini

Would love to Stay Connected with you ❤️

#NamasteJS #AkshaySaini
Рекомендации по теме
Комментарии
Автор

How was the video? Are you feeling excited? Please comment below. ❤️

akshaymarch
Автор

Man, indians are the best at teaching stuff. Cheers from Brazil!

mayaamano
Автор

Summary
1. Whenever any JavaScript code is executed an execution context is created and it is the Global Execution Context.
2. An Execution Context is basically a box which has two components called Memory Component(Variable Environment) and Code Component(Thread Of Execution).
3. The Execution context is created in two phases
a. Memory Creation Phase : In this Phase, Memory is allocated to all the variables and functions which are present in the global scope. Special keyword Undefined in case of variables and literally the whole function in case of functions.
b. Code Execution Phase : In this Phase, code is executed line by line.

4. Whenever there is a function invocation an all new execution context is created and same process is followed again.
5. If there is any function parameter then it is also allocated memory while creating the execution context of the function.
6. Whenever return keyword is encountered, it means the task of function is over and it returns back the control of the program back to the place where it was invoked. and with this this execution context is deleted from stack.

7. Call Stack is basically a stack which maintains the order of execution of execution context. Whenever a code is executed the Global Execution Context is pushed into the stack first and later on as per the function invocation the execution context is pushed into the stack. When the function code is done executing the execution context is popped out and last the Global Execution Context s also deleted.

yashpaota
Автор

I've never smiled with excitement during a programming explanation video until today. This guy is most excellent at explaining concepts!

SierraGax
Автор

Summary of this video - As we have already discussed in the last video that everything happens in javascript in the execution environment. So the entire execution happens in two phases as follows
1. Memory allocation phase- all the variables and functions get their memory allocated in the memory with undefined and the entire code respectively.
2. Code execution phase - in this phase thread execution happens and all the variables get their actual values which were assigned to them and as function is invoked, a new execution environment gets created in the code part, and again there are two phases, memory allocation phase and code execution phase. And the cycle repeats.

sagarpatel
Автор

This guy just explained something that takes 3 hours in 23 mins... I never usually comment on videos unless it makes a big impact, you my friend, are the best JS instructor i've ever seen. Keep it up!

emmanueljoseph
Автор

Sir: What is function?
Student: Function is beautiful

srijansingh
Автор

1. When JavaScript code is executed, Execution Context is created and it is called Global Execution Context.
2. JavaScript program is executed in TWO PHASES inside Execution Context
a. MEMORY ALLOCATION PHASE - JavaScript program goes throughout the program and allocate memory of Variables and Functions declared in program.
b. CODE EXECUTION PHASE - JavaScript program now goes throughout the code line by line and execute the code.
3. A Function is invoked when it is called and it acts as another MINI PROGRAM and creates its own Execution Context.
4. Returns keyword return the Control back to the PREVIOUS Execution-Context where the Function is called and Execution Context of the Function is DELETED.
5. CALL STACK maintains the ORDER of execution of Execution Contexts. It CREATES Execution Context whenever a Program starts or a Function is invoked and it pops out the Execution Context when a Function or Program ENDS.

kunal
Автор

came here from the odin project's website where this video was listed as an additional non-mandatory resource. that's where they're are wrong, this video is an absolute gem and a must for anyone looking to get started in JS

yasirmehmood
Автор

This is not just quality content, this is Gold Content...

prakalpvarshney
Автор

Been coding with js for many years now and honestly this is the first time I get to appreciate its beauty and truth be told really understand what's happening behind the scene. All thanks to you Akshay. This deserves a million view, and wish you more success! GOD BLESS!!! :)

karljosebuena
Автор

This is pure gold.
All the context of what happens behind the scene is important in grasping any idea and it is indeed beautiful.
Thank you for making this course.

ashishchourasia
Автор

One of the best, clear, easy to understand Javascript serie in the Internet history. I can truly say that this guy have special talent on teaching.

q
Автор

Literally Binge watching "Namaste JavaScript" playlist.
Thank you for giving so much of knowledge to us for free.

ayikkathilkarthik
Автор

Proud to be Indian. Look at how flawlessly he told it 🔥

shivampathak
Автор

You have a gift for explaining something in the most BEAUTIFUL way. There's no way you're not a university teacher or something. THank you very much!

DarkReaperK
Автор

One of the best JavaScript Series with an enthusiastic person which makes it easy to learn ( not like boring courses ).

rajatmalviya
Автор

22:53 love how he starts numbering the names from 0. Programming nerds know what i am talking about.

demonslayer
Автор

Now, I understood why JS is not taught in colleges. 🙏🙏

shobitjain
Автор

It feels like it is illegal to watch such invaluable content for free. Its a pure and absolute knowledge with 0 cost. Thankyou soo much akshay saini sir, god bless you always.

nikhilflautist