π Add to Chrome β Itβs Free - YouTube Summarizer
Category: Programming Basics
Tags: ExecutionJavaScriptProgrammingSingle-threadedSynchronous
Entities: AjaxJavaScriptNamaste JavaScript
00:00
Do you know how JavaScript works and how the code is executed? Is JavaScript synchronous or asynchronous?
Is JavaScript singlethreaded or is it multi-threaded? Don't worry, we'll cover everything.
Just keep watching. Namaste JavaScript.
00:15
Before I start explaining, listen to this first core fundamental. It is everything in JavaScript happens inside the execution context.
I repeat everything in JavaScript happens inside the execution context. You can assume
00:31
this execution context to be a big box or a container in which whole JavaScript code is executed. So let us now see how this execution context actually looks like.
So follow along with me. So now watch this carefully.
So execution context is like a big box
00:49
and it has two components in it. The first component is also known as the memory component.
So this is the place where all the variables and functions are stored as a key value pairs. Something like this.
So key value if
01:05
suppose we have a variable A which is equivalent to 10, it will be stored over here. And similarly functions are also stored over here in this memory component.
There is also a heavy word for this memory component. And this memory component is also known as variable environment.
Okay. So listen to
01:22
this carefully. Variable environment.
So it's sort of an environment in which all these variables and functions are stored as the key value pairs something like that. The second component of this execution context is the code component.
01:40
So here is it. So this is the place where code is executed one line at a time.
So this is the place. So just like this memory component is also known as the variable environment, there is also a heavy word for this code component.
It is also known as thread of execution. I
01:58
repeat thread of execution. So this is also known as the thread of execution.
So this thread of execution is just like a thread in which the whole code is executed one line at a time. So here's the time for another core fundamental.
02:13
Listen to this really very carefully. So JavaScript is a synchronous singlethreaded language.
So this is really very important. JavaScript is a synchronous singlethreaded language.
So let us see what does this means. So when I say singlethreaded that means
02:29
JavaScript can only execute one command at a time. And when I say synchronous singlethreaded that means that JavaScript can only execute one command at a time and in a specific order.
Okay. So that means that it can only go to the
02:45
next line once the current line has been finished executing. So that means synchronous singlethreaded language.
So let's revise once again. JavaScript is a synchronous singlethreaded language.
I know that you must be thinking then we have heard of something known as Ajax,
03:02
right? Where a stands for asynchronous.
So what does that means? Don't worry, we'll cover everything.
We'll be going slowly and we'll be understanding each of these concepts properly as we go ahead. So for now just remember that JavaScript is not possible without this
03:18
beautiful execution context. So let's just quickly recap what we studied.
This whole thing which you can see is the execution context. The first component is known as the memory component.
The second component is known as the code component. Memory component contains variables and functions as the key value
03:33
pairs. And this code code component is the place where whole JavaScript code is executed.
Memory component is also known as the variable environment and the code component is also known as the thread of execution. I know these are a lot of jarens and
03:49
trust me these things are really very important and nobody teaches them but I am here on a mission to make you fall in love with JavaScript and don't worry continue along with me and we'll be covering everything in deep. So in the next video I'll actually walk you through a real JavaScript program.
We
04:04
will see how this whole beautiful execution context is created. How this memory section is created.
How this code is executed inside this code component. Everything we'll cover in the next video.
But before jumping on to that video, you have to do two things. First is to like this video.
It gives me a
04:20
huge motivation. And the second thing is to comment down what you liked about this video and are you feeling excited or not.
So that's all in this video and thank you for watching. Namaste JavaScript.
[Music]