Hoisting is the moving of declarations to their respected scopes.

 

 

Function hoisting

 

// <---- the defined function is hoisted to here

sayHello()

function sayHello() {
   console.log("hello")
}

 

Variable hoisting

 

// <---- variable is hoisted here

x = 10

console.log(x)

var x