DEV Community

PUSHAN VERMA
PUSHAN VERMA

Posted on

Hoisting and Temporal Dead Zone

Hoisting

console.log('varname',varName);
var varName;
console.log('varname',varName);
varName ="captain america";
console.log('varname',varName);

fn();
function fn()
{
console.log("hello from fn");
}
fn();

Image description

Temporal Zone

//temporal dead zone is a zone where the variable is in accesible

with var
console.log(a);
var a =2;
op-undefined

with let
console.log(b);
let b=3;

op -(Error ) Missing initializer in const declaration

with const
console.log(c);
const c=4;

op -(Error ) Missing initializer in const declaration

Top comments (0)