Search code examples
javascripttypeof

Calling JavaScript typeof as operator vs function


I've seen typeof being called as an unary operator and as what it looks like a function:

typeof "bla"  // like a unary operator
typeof("bla") // like a function

But is it really being called as a function or it's just an expression that looks like a function call? Like this:

typeof ("a string surrounded by parens")

I looked at the spec and it seems it's just an unary operator. But I'm not good reading the spec.


Solution

  • The second one

    typeof("bla")
    

    it is the grouping operator (), not part of a function call.