Now we are on Section three coding basics, so we're going to get past the environment that we learned
about in Section two, the history of JavaScript, into a lot of actual coding now.
So first things first, Section three.
Lesson one is about the execution context.
This is more of an abstract idea.
So we're not going to learn a whole lot of code in this lesson.
The whole purpose of this lesson is to understand how JavaScript runs.
And really, it's just the idea that whenever any code is run in JavaScript, it's run inside a specific
execution context.
So there are three that we'll learn about.
There's the global execution context, the functional execution context and the evil execution context.
So let's take a look at those in code.
So we've looked at this before.
We're looking at the example from the end of our coding challenge from section to.
And we have a global execution context in this script that basically refers to anything that is set
up and run at the highest level of the code.
For example, this variable declaration right here, MSgt for message.
This is run at the global execution level.
There is also a function which is defined globally.
But then the contents of this function are inside of another code block, and these are running in a
functional execution context, that just means that they are running inside the function.
And the purpose of execution context is more of a memory usage.
So it's just saying that this is its own script within a script is what functions are.
So it's a block of code that's going to run inside of this other larger script.
So it's like.
The global execution context is running on top of that, you may have a function that runs.
And that it would be a second execution context and then a third execution context is eval.
So evil, basically, you can use to evaluate JavaScript code and execute it.
It's not recommended that we use this anymore.
But you can it's not nobody's going to slap your wrist, but definitely it's something that is deprecated,
mostly replaces functionality, better functionality that we use in the general context.
So I would recommend not using eval.
It's not necessary to run your proper code.
And the reason it's not preferred is that because it runs in its own execution context, it runs its
own set of memory.
So it uses memory on your computer.
And it does so with less efficiency than the global execution context and the functional execution context.
So we can refresh this and it will execute that code for us and it will do it inside its own context,
but generally it's understood that, you know, we don't prefer to use eval, OK?
So we're going to go ahead and comment that out.
And make a note here as well.
Eval is not preferred in its six plus, which is the current version of JavaScript.
OK, so that's pretty much it for lesson one, the execution context.
We just wanted to show you the difference between the global execution context, where anything happens
at this top level, the functional execution context, where anything inside a function will run it
in its own process.
And then this no longer used evil process, which you can use to run code in its own context as well.
OK.
How the order of these operations happened, when it's running the script, it will run the global context
first, then it will run any functions.
And if it has any events, it will run those as well.
OK, that's it for lesson one on to listen to and to listen to.
We're going to be talking about single line and multiline commenting and type coercion and variable
mutation.
OK, see you soon.