Why is the `typeof` operator formatted differently from other operators?

Thanks, I have a whole folder dedicated to MDN pages for fast reference.

1 Like

So an operator is “global” because it is asking about a more general property of a data type and an object attribute is more specific to a particular value?

Operators are global because they can be applied anywhere, and in some cases on any type of data. Objects contain their data and methods and either they inherit from a built in class, or they are instances of a custom class.

1 Like

I think @serraphus was meaning to ask why is console.log(type newVariable); not written as console.log(newVariable.typeof());?

typeof is a global operator. It would make very little sense to have a typeof method on every class, including the ones we create.

1 Like