Variable Environment

Variable Environment is a place that variables can live in different stack worlds. They all technically live in the JavaScript engine memory heap but they need to know how they related to between functions which functions have access to certain variables and some do not.

Variable Environment

function two() {
  console.log("function two: " + isValid);
}
function one() {
  var isValid = true;
  console.log("function one: " + isValid);
  two();
}
var isValid = false;
console.log(isValid);
one();
false
function one: true
function two: false

Each execution context has it own variable environment.

Leave a Reply

Your email address will not be published.

ANOTE.DEV