+2 votes
in Programming Languages & Algorithms by
lexical environment in Javascript definition

1 Answer

+1 vote
by (13.6k points)
 
Best answer

Lexical Environment is an abstract container in the Javascript engine that holds the identifier-variable mapping. Consider the example below:

function getWebsiteName(){

var website = 'CPEN Talk';

console.log(website);

}

getWebsiteName();

When you define a variable as done in the function above, the internal Javascript engine maps the name of the variable (website) to the variable (reference to the actual object).

For every new function call, a new function execution context is created and added to the execution context stack with its corresponding lexical environment.

...