So I get how typeof can be an operator or a function. But when I do
console.log(typeof(typeof));
I got this message Uncaught SyntaxError: Unexpected token ')'
So what am i doing wrong here? What can i do to get the data type of typeof?
typeof is an operator. (Source: MDN Web Docs: typeof.)
To sum up the documentation on operators, I'll say this: Every operator must work on an operand (or non-operator). A unary operator requires only one operand (i++, !j), a binary operator requires two operands (1+2, 'a' + 'b'), and there's even a special ternary operator. (Source: MDN Web Docs: Expressions and operators.) Or, if you like the original text...
A binary operator requires two operands, one before the operator and one after the operator...
A unary operator requires a single operand...
So, it's not possible to do...
+ ++ ==typeof +Etc.. Naturally, then, typeof typeof will naturally not work, as it violates the rule about unary operators requiring operands.
typeofis only an operator.typeof(+)(ortypeof +, since it is indeed an operator and therefore doesn't need parentheses) fails with the same error, which hopefully isn't a surprise. Despite it being all alphanumeric characters,typeofis an operator just like+and friends, so it behaves the same way.