Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
Need Clarification on Execution Context
function a(){
    b();
    var c;
}

function b(){
    var d;
}

a();
var d;

I would like a clarification on Execution Context for the code above. From what I understand, during the creation phase of Execution Context functions a and b are set as pointers to the location in heap memory and var d is set to undefined. During the execution phase, function declarations a and b are simply ignored.

What I'm confused about is when we invoke function a during execution phase, is Global Execution Context is still in execution phase later when we pop a()'s execution context from a stack, so we can process var d? Or is GEC's execution phase is over once we invoke a() and then we somehow scan the var d when GEC is the only context left on a stack?

From what I understand, after GEC execution phase, a() will be invoked and new a() execution context will be put on execution stack. Then after a()'s execution phase is done, we put new b() execution context on a stack. After we pop b()'s execution context, we can process var c and after we pop a()'s execution stack we can process var d of global execution stack.

The biggest confusion is how JS engine checks var c and var b if execution phase for both contexts is already over. Is execution phase for previous context actually over or is it still running for each context? Are we able to scan var c and var d due to a Variable Object(VO) saving information about current execution context or due to all previous execution contexts still running an execution phase? I do not understand whether execution phase for given context is finished on function invocation of a next context or when we pop a current/given context from a stack.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

So, the callstack in js works on LIFO, considering your example the execution context will be executed in following manner

  1. Initial

[gec]

  1. invoking a()

[a execution context]

[gec]

  1. invoking b()

[b execution context]

[a execution context]

[gec]

  1. b() finished execution

[a execution context]

[gec]

  1. a() finished execution

[gec]

I hope this helps you!!!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!