Monday, August 23, 2021

What is execution context?

When a JavaScript functions call then an execution context is put on top of the execution stack. Below is the structure of a execution context object.




--Variable object(VO): All the parameters are passed to a function is stored in VO. 
--Function declaration is stored into VO to pointing a function. 
Variables are scanned and for all variable a property is created in VO and set to undefined which is called hoisting .
Hoisting means they are available before execution.We will know more about in the next.

let and const

They are not stored in the old Variable Object like var.

let age = 20;

const PI = 3.14;

They go into a separate Lexical Environment.

They exist in the Temporal Dead Zone (TDZ) until execution reaches their declaration.


No comments:

Post a Comment

Javascript module

JavaScript Modules (ES6) let you split code into multiple files and reuse code cleanly. Main keywords: export → make something available...