JavaScript Execution Context & Lexical Environment (5) | JavaScript Behind the Scenes

Pubblicato il: 09 September 2022
sul canale di: Shadow Coding
4,792
261

You can contact me here.

Facebook:   / mostafashadow1  
Linkedin:   / mostafashadow1  

If you're writing JavaScript code, let me give you a quick tour and explain what Execution Context is. Look, my friend, our amazing JavaScript engine, when you create a JavaScript file, even if it's empty and indexed, what does it do when the file runs? It creates something called Global Execution Context. It creates something we don't see in our code, like space itself—a world of its own. The code we write is inside its world.

What does this mean?

Let me explain simply.

Imagine space with planets, right? Amazing! And there are other things too. All of these things are inside space, just perfect.

Example,
var place = “Mostafa”
Where is this variable in our world now?

Inside the space that is the Global Execution context.

That's great. Now, if I want this place to be inside planet Earth, here's a problem.

I have to go to the JavaScript engine and ask, "Can you create another world called planet Earth?"

It will say, "Sure," but there's a condition for doing that.

The condition is that you have to create a function so that I can create a new execution context. So far, we know what's required of us. Let's start implementing it.

function name () {
var place = “Mostafa”
}
name();

So, it created a planet 🌍 inside space, right?

But this planet now has a separate context, meaning I can put things inside the planet, and they won't be inside space. I think you understand what I mean.

You might encounter a term like this.

Lexical environment.

Simply put, the JS Engine tries to determine which realm our code is in. Is it in the global space?

Or in another realm within space, so it can execute it? That's all.

JavaScript explanation
JavaScript tutorial
JavaScript
JavaScript project
JavaScript behind the scenes
JavaScript DOM
JavaScript OOP
JavaScript explanation
JavaScript examples
JavaScript course
Learn JavaScript in Arabic
JavaScript course
Learn JavaScript
JavaScript BOM
JavaScript course
Learn JavaScript
Advanced JavaScript
JavaScript in Arabic
JavaScript advanced
JavaScript course
JavaScript full course
What is JavaScript?

#javascripttutorial #js #javascript


In questa pagina del sito puoi guardare il video online JavaScript Execution Context & Lexical Environment (5) | JavaScript Behind the Scenes della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Shadow Coding 09 September 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 4,792 volte e gli è piaciuto 261 spettatori. Buona visione!