-
Creation Phase:
- Memory is allocated for variables and functions.
- Variables are initialized with
undefined
. - Functions are stored as-is.
-
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