简体   繁体   English

我怎么知道括号指的是什么

[英]How do I know what the parentheses refer to

In the second statement, since the parentheses are optional, how do I know if the parentheses are part of the first constructor, the second, or if it is calling a function that does not do anything? 在第二条语句中,由于括号是可选的,我如何知道括号是第一个构造函数,第二个构造函数的一部分,还是它正在调用不执行任何操作的函数?

function A(){return function(){}}
new new A()

By looking at the precedence and associativity of the operators. 通过查看运算符的优先级和关联性。 new with parentheses has higher precedence than function call and new without parentheses and the associativity is right so the parentheses goes to the right most new. 带括号的new的优先级高于函数调用和带括号的new的优先级,并且关联性是正确的,因此括号以最右边的最新的形式出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM