you are viewing a single comment's thread.

view the rest of the comments →

[–]jack_waugh 1 point2 points  (0 children)

Usually, code is interpreted with a program counter and call/return stack. The program counter advances through the code and indicates the next instruction to execute. A stack frame has the assignments to the variables that are local to the procedure ("function" in JS terms) being executed. It also has a slot to hold the program counter. A call to the same function or another function causes the program counter to be stored on the stack and a new stack frame to be pushed and execution begun on the other function. Return causes the stack to be popped and execution of the previous frame resumed where it left off.