为什么“& typeof&"与& quot; typeof()& amp; quot;相同吗? [英] Why is "typeof" the same as "typeof()"?

查看:69
本文介绍了为什么“& typeof&"与& quot; typeof()& amp; quot;相同吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习JavaScript,并且在代码中看到使用 typeof typeof()的代码是相同的,例如:

两种情况下的结果均为数字

  console.log(typeof 1);console.log(typeof(1)); 

根据 解决方案

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.

这篇关于为什么“& typeof&"与& quot; typeof()& amp; quot;相同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆