JavaScript hoisting function vs function variable
Here is my javascript code : console.log(a); c(); b(); var a = 'Hello World'; var b = function(){ console.log("B is called"); } function c(){ console.log("C is called"); } Now here is output : undefined hoisting.html:12 C is called hoisting.html:6 Uncaught TypeError: b is not a function My question is regarding why c() and b() behaving differently. And b should throw error something like b is not defined. soundyogi A Function Declaration will be hoisted along with its body. A Function Expression not, only the var statement will be hoisted. This is how your code "looks" like to the interpreter