I want to know why the result of the typeof name of function inside if condition gives "undefined".
if i try this code the get the typeof the name of function, i receive the result "function".
function calc(){}
console.log(typeof calc); //The result is "function"
but, if i try to put the function inside if condition like that i receive the result "undefined".
if(function calc(){}) {
y = typeof calc;
}
console.log(y); //The result is "undefined"
How the function works inside the if condition and why the result of typeof is "undefined"?
The same result i receive if i try to get the typeof any other string
if(function calc(){}) {
y = typeof z;
}
console.log(y); //The result is "undefined"
if(function calc(){}) {
y = typeof nothing;
}
console.log(y); //The result is "undefined
I know that the default value of a variable is "undefined" and the result of the function that doesn't return any value is "undefined", but i can understand how it works inside the if condition and why the result if "undefined".