Functions are beautiful- Akshay Saini.
Suppose we have this code
(You can consider like, a towel which Indians keep on the seat in bus to book it 😂 xD)
now comes the code execution phase, where every calculation and assignment of actual value is done, so here the value x is assigned 10 , before that we are printing x, so as we said it should have…. undefined!
and then directly executes the code as per the line number 4, now here is the beautiful part, now whenever a function is called that function is pushed on the call stack and an entire execution context is created with memory allocation phase and code execution phase,
Here now this function acts as an entire different program with all variables and function calls differently and now x is again given a value of undefined in the memory allocation phase and in the code execution phase, it is assigned its real value and when the last line of that function is executed by printing value of x, the function is popped off the call stack and that execution context is destroyed,
Our Final Output:
Similarly when the last line of the actual code is executed, entire global execution context is destroyed. It is soo beautiful!!
ever wondered how Async would be working in this world of single threaded language 👀 ,stay tuned, will cover that too!
Meme of the week!!
ik ik, it’s so beautiful isn’t it?
Thank you for reading it till here!
Stay Safe, Stay Happy!