圆括号运算符( ) 用来控制表达式中的运算优先级。

语法

 ( )

说明

圆括号运算符由一对圆括号组成,包裹表达式和子表达式用来覆盖常规的 运算符优先级 ,达到低优先级的表达式比高优先级的表达式更早运算.

示例

下面的代码展示了加法运算先于乘法运算的情况.

var a = 1;
var b = 2;
var c = 3;

// default precedence
a + b * c     // 7
// evaluated by default like this
a + (b * c)   // 7

// now overriding precedence 
// addition before multiplication   
(a + b) * c   // 9

// which is equivalent to
a * c + b * c // 9

规范

Specification Status Comment
ECMAScript Latest Draft (ECMA-262)
The Grouping Operator
Draft  
ECMAScript 2015 (6th Edition, ECMA-262)
The Grouping Operator
Standard  
ECMAScript 5.1 (ECMA-262)
The Grouping Operator
Standard  
ECMAScript 1st Edition (ECMA-262)
The Grouping Operator
Standard 初始化定义.在JavaScript1.0中生效

浏览器兼容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic supportChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes

Legend

Full support  
Full support

相关链接

文档标签和贡献者

此页面的贡献者: Idealist_EZ, zhangchen, yenshen
最后编辑者: Idealist_EZ,