In the below code snippet, why I am getting the error inner is not a function?
var inner = 10;
function inner() {
console.log("Hey type", typeof inner);
}
inner()
Because of the way hoisting works in javascript the inner function declaration is fully declared (and callable) before the inner-variable gets assigned the number value. So you are actually overriding the inner function with a number in line 1.
Using a function expression instead will output the result function. I guess that is what you expected.
var inner = 10;
var inner = function() {
console.log("Hey type", typeof inner);
}
inner()