Prepare for the Salesforce JavaScript Developer Exam. Utilize comprehensive quizzes, flashcards, and multiple choice questions with hints and explanations. Boost your exam readiness!

Practice this question and more.


What will be the output when executing: console.log(typeof typeof 1);?

  1. "number"

  2. "string"

  3. "object"

  4. "undefined"

The correct answer is: "string"

When executing the expression `console.log(typeof typeof 1);`, the innermost `typeof` operator evaluates the expression `1`. Since `1` is a number, the first `typeof` returns the string `"number"`. Next, the outer `typeof` operator evaluates the result of the first `typeof` operation, which is the string `"number"`. The `typeof` operator determines the type of its operand, which in this case is the string `"number"`. Since the type of a string is classified as `"string"`, the outer `typeof` returns `"string"`. Therefore, the final output of the entire expression is `"string"`, making it the correct answer. This demonstrates how the `typeof` operator behaves in nested operations and highlights its return values based on the types of the evaluated expressions.