그룹 연산자

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

그룹 연산자 () 는 표현식 내에서 평가의 우선순위를 제어합니다.

시도해보기

console.log(1 + 2 * 3); // 1 + 6
// Expected output: 7

console.log(1 + 2 * 3); // 1 + 6
// Expected output: 7

console.log((1 + 2) * 3); // 3 * 3
// Expected output: 9

console.log(1 * 3 + 2 * 3); // 3 + 6
// Expected output: 9

구문

js
     ( )

설명

그룹 연산자는 표현식이나 중첩 표현식 주위를 감싸는 한 쌍의 괄호로 이루어진 연산자로, 감싸인 식이 더 높은 우선순위를 갖도록 일반적인 연산자 우선순위를 재정의합니다. 이름 그대로, 그룹 연산자는 괄호 안의 내용을 묶습니다.

예제

다음 예제에서는 곱셈과 나눗셈 이후 덧셈과 뺄셈을 사용하는 일반적인 연산 순서를 그룹 연산자를 사용해 바꿉니다.

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

// 기본 우선순위
a + b * c; // 7
// 이것과 같음
a + (b * c); // 7

// 더하기를 곱하기보다 먼저 하도록
// 우선순위 변경
(a + b) * c; // 9

// 이것과 같음
a * c + b * c; // 9

명세서

Specification
ECMAScript® 2025 Language Specification
# sec-grouping-operator

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
Grouping operator ()

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

같이 보기