Hoisiting

Define -: Accessing a variable before defining it without getting an error.


1.Variable

console.log("x",x)

var x= 7;


it will print undefined.


2.Function 

console.log(fun)


function fun()

{

console.log("HELLO")

}

it will print the function itself.

3.Arrow Function

arrow function behaves like a variable and it will say function is not defined or declared if we access it before define.








Comments

Popular posts from this blog

event loop and callback queue ,call stack