In this video.
Let's dive in.
More to talk about cost.
So again, what is called stuck where the cost tag is a data structure that is used to track the execution
of function calls.
Well, so let's see the steps involved.
Let's say that we have the function that we want to call.
Remember, we have two types of code that we write, whether asynchronous programming code or asynchronous
code.
So when you say asynchronous code, they are code that does not block other code from running.
But for asynchronous programming or code, the code blocks other from run, meaning it runs in order,
as you saw in the previous video.
That's why it says that JavaScript is a single threaded programming language, but it also says that
JavaScript is also non blocking.
So now let's say that we have this function that we want to run.
Let's see the flow.
Well, first of all, this function will be passed to what is called event loop.
But before it gets even loop, the function will put on to what is called callback queue.
Well, so the event loop manages which callback function to be put inside the code stack.
So in the mix here, we have a component called the callback queue.
So this function we put inside this callback queue and the event loop will always check.
Is there any function or callback that has to be executed?
Then the event loop will put it inside the callback.
So let's see.
So now the event loop is now checking where we have a function to be called, assuming this function
has been pulled inside the callback queue.
Have a look.
Now, the event loop will now put this function inside the coaster.
And then assuming there's is a function that you want to call now, it is inside our stack.
And let's say that we have, let's say, three functions that you want to call.
So the event loop always put it inside on a code stack as that.
Now, assuming that it's yet to be executed well, so in the first run, let's say that this function
has finished executing, then it'll pop up from the call stack.
Likewise, the other one finishes, it pops up and lastly also finishes pop up.
And lastly, our costs are destroyed.
So that is it about the cost in a basic flow?
Well, with this concept in mind, to help you to understand the next topic that we are going to talk
about what is called asynchronous and synchronous programming.
Well, we always revisit this idea to enhance our knowledge when it come to JavaScript.