Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda