0
Can a object be used without parentheses?
Like so if we are calling a function typeof in js and instead of typing the value in curve brackets, it is typed after the typeof by giving a space in between them. Is typeof("str") == typeof "str"?
3 Respuestas
+ 3
Aman Kumar ,
>It's working.
Yes. There is no reason for it to NOT work. It's same as adding parentheses around any other other literal value.
Just like +"4" is same as +("4"),
typeof "str" is same as typeof("str"), but you really don't need ( ) here.
You might need ( ) when you need to get typeof value that an expression evaluates to. If the expression contains operators that have lower precedence than `typeof` use ( ) to group the expression.
example.
`+` has lower precedence than `typeof` ¹
alert(typeof 9+9); //number9
alert(typeof (9+9)); //number
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
+ 2
typeof is not a function. it's an operator.
0
Can you explain in detail. It's working.