0 votes
in JavaScript by
What's the output?

function sayHi() {
  return (() => 0)();
}

console.log(typeof sayHi());
  • A: "object"
  • B: "number"
  • C: "function"
  • D: "undefined"

1 Answer

0 votes
by

Answer: B

The sayHi function returns the returned value of the immediately invoked function expression (IIFE). This function returned 0, which is type "number".

FYI: typeof can return the following list of values: undefinedbooleannumberbigintstringsymbolfunction and object. Note that typeof null returns "object".

...