Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 695 Bytes

what_are_the_phases_of_execution_context_.md

File metadata and controls

28 lines (19 loc) · 695 Bytes

What are the phases of execution context?

  1. Creation Phase:

    • Memory is allocated for variables and functions.
    • Variables are initialized with undefined.
    • Functions are stored as-is.
  2. Execution Phase:

    • Code is executed line by line.
    • Variables are assigned actual values.

Example:

function test() {
  console.log(a); // undefined (creation phase)
  var a = 10;
  console.log(a); // 10 (execution phase)
}

test();

Tags: intermediate, JavaScript, Execution Context