[英]Javascript operator precedence technicality
I'm having a hard time understanding what is meant by the combination of Exponentiation and everything else (Multiplication, Division, etc) in group 14 of the Javascript precedence. 我很难理解在Javascript优先级的第14组中,Exponentiation和其他所有内容(乘法,除法等)的组合意味着什么。
Three questions: 三个问题:
1) 2 ** 3 ** 4
, being right-to-left associative, is 2 ** (3 ** 4)
. 1)
2 ** 3 ** 4
,从右到左关联,是2 ** (3 ** 4)
。 2 / 3 / 4
, being left-to-right associative, is (2 / 3) / 4
. 2 / 3 / 4
,从左到右关联,是(2 / 3) / 4
。
2/3) I believe 2 ** 3 * 4
is (2 ** 3) * 4
. 2/3)我相信
2 ** 3 * 4
是(2 ** 3) * 4
。 2 * 3 ** 4
is 2 * (3 ** 4)
(as evaluated by es6fiddle ). 2 * 3 ** 4
是2 * (3 ** 4)
(由es6fiddle评估)。
This does not follow from the table; 这不是从表中得出的; but exponentiation should have precedence over multiplication.
但取幂应优先于乘法。 Mixing left-to-right and right-to-left in one precedence rank is strange.
在一个优先级别中从左到右和从右到左混合是很奇怪的。 In fact, as far as I could see in ES7 drafts , it is not at all treated grammatically the same way as
*
, /
and %
, but as a unary operation (!). 事实上,就我在ES7草案中所看到的而言,它在语法上与
*
, /
和%
,而是作为一元操作(!)。
Also note that no engines other than Babel and Traceur have support for **
at the current time, so it is mostly academic at this point. 另请注意,除了Babel和Traceur之外,目前没有任何引擎支持
**
,所以此时它主要是学术性的。 MDN is a wiki, and exponentiation operator was added by a Mozillian; MDN是一个wiki,并且由Mozillian添加了取幂运算符; but AFAIK since Mozilla doesn't currently support
**
, it does not actually document the way Mozilla interprets the language. 但是AFAIK,因为Mozilla目前不支持
**
,它实际上并没有记录Mozilla解释语言的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.