Successfully added
JavaScript
by Patrik
Hoisting of var
Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution. This means that if we do this:
console.log (greeter);
var greeter = "say hello"
it is interpreted as this:
var greeter;
console.log(greeter); // greeter is undefined
greeter = "say hello"
So var
variables are hoisted to the top of their scope and initialized with a value of undefined
.
Referenced in:
Comments