I know Javascript create Global Execution Context and put them on the Execution stack and go through two stages, Creation stage, and Execution stage, on the second stage when it finds a function being invoked it creates an another execution context and put that execution context on the top of the execution stack, and repeats the same thing, once the code in the function finishes executing, it popped off the top of stack, return to execution context below in the stack. But my question is that how does Javascript deal with code blocks of condition statements or loops?
if (true) {
//this is not the right way to write code.
var var1 = 1;
var var2 = 2;
var3 = 3;
function someFunction(arg1, arg2) {
//code
}
someFunction('value1', 'value2');
}
Does the Javascript engine do the same thing when it enters a code block of condition statements or loops? what actually it does?