223k views
4 votes
What would following code return?

(typeof typeof 1);

1 Answer

4 votes

Final answer:

The code (typeof typeof 1) returns the string 'string'.

Step-by-step explanation:

The code (typeof typeof 1) would return the string 'string'.



In JavaScript, the typeof operator returns the type of a value. However, when used twice in a row, it performs the operation on the resulting type of the first typeof operator.



Since the typeof operator returns a string, typeof typeof 1 will return the string representation of the type of a string, which is 'string'.

User Cedric Ziel
by
8.1k points