The ULTIMATE guide to JavaScript Execution Contexts 🔥

  Рет қаралды 1,297

EDUDREAMS

EDUDREAMS

Күн бұрын

Javascript - Execution Context|Lexical Environment
00:07 Execution Context
08:29 Lexical Environment
13:55 Hoisting
24:40 Exercise Hoisting
28:34 Exercise Hoisting 2
how do we run code in JavaScript well we assign variables and then we run functions right that's all we really do in a language so take a look at the code over here
every time we run a function let's say if we call the say my name function we add these brackets to it and then we're able to execute that function or run it the JavaScript engine is going to look at this and say aha here's a task for me tell me what to do Mr function and as soon as the JavaScript engine sees these brackets it's going to create something called an execution context but we'll get to that in a second if we run this function say my name is going to be run which is going to return find name which is going which is going to return print name which is going to return my name all right that's a pretty convoluted way of doing things but if I run this we see that it prints Andre nagway so what is happening here well when the JavaScript engine sees those brackets it's going to say oh I'm going to run a function and create an execution context so the first thing it does is create an execution context say my name and add this execution context onto the stack remember our call stack right and then it tries to run this function and sees that oh this function is calling another function so I'm going to create a new execution context because I'm going to see these brackets that's called find my name and there we have it another item that gets pushed onto the stack and then that function once the script engine is going to see oh here's another bracket pair of brackets print name let's run this function and then this function after it's created its own execution context is going to return the string Andre nagway which gets returned to find my name which gets returned to say my name and then eventually the call stack all gets popped off and we return onto the screen Andre nagway it's really weird saying my own name while doing this next time I'm going to pick a different name so if we take a look back onto our code this should make sense we're adding items onto the call stack which we've talked about before but this time I've introduced to you this idea of execution context now before we get into exactly what this execution context means I may have lied to you the diagram that we just saw isn't a hundred percent accurate 100 accurate because the base execution context that runs is called the global execution context this is what I mean initially our JavaScript engine is going to create a global execution context we don't see this it's underneath the hood but it's saying hey here's the Javascript file for you just start reading it for me and on top of that that's when we start adding say my name then find my name then print name and then eventually as these execution contexts get popped off the last thing that remains is the global execution context and when the final line of our code runs and we're done with the JavaScript engine
THANKS FOR WATCHING AND DON'T FORGET TO LIKE, COMMENT, SUBSCRIBE, AND HIT THE BELL ICON TO WATCH THE LATEST VIDEO!
#edudreams #js #javascript
~-~~-~~~-~~-~
Please watch: "String manipulation in Python #codingtutorial #python #programminglanguage #coding"
• Make Python Work For Y...
~-~~-~~~-~~-~

Пікірлер
Database Engines: The Ultimate Guide
1:01:27
EDUDREAMS
Рет қаралды 205
МЕБЕЛЬ ВЫДАСТ СОТРУДНИКАМ ПОЛИЦИИ ТАБЕЛЬНУЮ МЕБЕЛЬ
00:20
Шок. Никокадо Авокадо похудел на 110 кг
00:44
Here's How NVIDA's New 'Eagle Eye' Will Change The World Forever
10:41
Building a Short URL System Database Backend
37:57
EDUDREAMS
Рет қаралды 240
Type Juggling and Coercion in PHP
10:24
Frank Prins
Рет қаралды 69
Database Sharding
1:13:48
EDUDREAMS
Рет қаралды 1,4 М.
Secrets to Mastering Database Indexing
58:41
EDUDREAMS
Рет қаралды 238
Should You Learn Coding in 2024
9:56
EDUDREAMS
Рет қаралды 43
Data Base : Mastering Concurrency Control Techniques
1:15:23
The Surprising Truth about Database Replication
31:11
EDUDREAMS
Рет қаралды 36
МЕБЕЛЬ ВЫДАСТ СОТРУДНИКАМ ПОЛИЦИИ ТАБЕЛЬНУЮ МЕБЕЛЬ
00:20