运算符优先级:!并等待

operator precedence: ! and await

在JavaScript中,下面的语句如何解释:

cond1 && !await f()

这是摘自行

if(cond1 && !await f()){
    do_stuff();
}

在生产应用程序中。 chrome 似乎没问题,但是在 ios 上这会导致错误读取

unexpected identifier 'f'. Expected ')' to end an if condition.

看起来好像 ios 把 !await f() 变成了 (!await)(f()) 而不是 !(await f())

现在回答我的问题:根据 ECMA-262 对上面一行的正确解释是什么?

p.s.: 我们已将 ios 的代码更改为

var f_result = await f();
if(cond1 && !f_result){
    do_stuff();
}

这与运算符优先级无关。由于两者都是一元前缀运算符,因此只有一种方式可以解释此表达式 - 所有 deletevoidtypeof+-~!await是同一个生产目标解析的,可以任意嵌套。是的,它是 ES2017 中的有效语法。