console.log((function f() { return typeof f; })());0
What is the output of this immediately invoked function expression (IIFE), and why does it behave that way?
subina kallyani
hard
1completed
45
Answer
The output will be: "function"
- The function is a named function expression with the name
f. - Inside its own body, the function name
frefers to itself, regardless of how the function was invoked. - Therefore,
typeof freturns"function".
Important Detail:
This name f is not available outside the function.
Example:
console.log(typeof f); // ReferenceError: f is not definedClick to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0