Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is "typeof" the same as "typeof()"?

Tags:

javascript

I'm learning JavaScript, and i saw in the code that is the same to use typeof and typeof(), for example:

The result is number in both cases:

console.log(typeof 1); 
console.log(typeof(1));
like image 873
Diego De Santiago Avatar asked Dec 20 '22 08:12

Diego De Santiago


1 Answers

typeof is, according to ES5 spec, an unary operator - the same as void and delete, for example. Wrapping its expression with grouping () is only done for convenience (and - in theory - to override the default precedence), but never it's treated as a function call.

like image 168
raina77ow Avatar answered Jan 03 '23 02:01

raina77ow