Salesforce JavaScript Developer Practice Exam

Question: 1 / 400

What is the output of the function sayHi when executed as follows: function sayHi() { return (() => 0)(); } console.log(typeof sayHi());?

"object"

"number"

The function `sayHi` is defined to return the result of an immediately invoked arrow function, which simply returns the value `0`. When the arrow function is executed, it evaluates to `0`.

In JavaScript, the `typeof` operator is used to determine the type of a value. When `sayHi` is called, it results in `0`, a number. Thus, when `typeof sayHi()` is evaluated, it checks the type of this returned value, which is `0`. The `typeof 0` gives the string `"number"`.

This is why the output of `console.log(typeof sayHi());` results in the string `"number"`. Hence, the correct answer is that the output of the function when executed in this manner is `"number"`.

Get further explanation with Examzify DeepDiveBeta

"function"

"undefined"

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy