In JavaScript typeof is an operator and a function. Is it better used as an operator or a function? Why?
In JavaScript typeof is an operator and a function. Is it better used as
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
typeofis an operator. You can easily check it using:Were
typeofa function, this expression would return'function'string, but it results in a syntax error:so,
typeofcannot be a function. Probably parenthesis-notationtypeof(foo)made you thinktypeofis a function, but syntactically, those parenthesis are not function call – they are those used for grouping, just like(2 + 3) *2. In fact, you can add any number of them you want: