Hoisting is the process by which we can access variables and functions even before initializing them.
Example:
console.log(num);
bsfun1();
var num=1;
function bsfun1(){
console.log("Bloggerspace");
}Output:
undefined
BloggerspaceExplanation:
This is because initially, memory is allocated to all the variables and functions, and when trying to console log the output before initializing the num, we get undefined due to the Execution Context.