Predict the output of the following javascript code
var x = 1;
if (function f() {}) {
x += typeof f;
}
console.log(x);
Quiz Explanation
The output is 1undefined
because the function expression inside the if
statement is truthy, and typeof f
returns "undefined"
since f
is only defined within the function scope. Learn