简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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