Favorites

JavaScript , Comma Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
,
JavaScript Other OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The comma operator evaluates several expressions from left to right and returns the value of the last one.

Description

The comma operator evaluates each of its operands from left to right and returns the value of the last. It has the lowest precedence of any operator. Its main legitimate use is updating several variables in a for loop's header. Commas in argument lists, array literals and variable declarations are separators, not this operator.

In variable declarations such as let a = 1, b = 2, the commas are part of the declaration syntax, not the comma operator, and the same is true for commas in function arguments, array literals and object literals. Because the operator has the lowest precedence, you need parentheses to use it in most other places, as in const x = (a++, b).

Outside the for loop header, the comma operator mostly appears in minified code, where it squeezes several expressions into one. In hand-written code, separate statements are clearer, and linters often flag the comma operator with rules like ESLint's no-sequences.

Properties

Operator
,
Category
Other
Precedence
1 (1 is lowest, 18 is highest)
Associativity
left-to-right

Syntax

expr1, expr2, expr3

Example

for (let i = 0, j = 10; i < j; i += 3, j -= 3) {
  console.log(i, j);
}
const x = (1, 2, 3);
console.log(x);

Browser Support

The following information will show you the current browser support for the , operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee