DEV Community

Cover image for Comma operator (,)
Nipu Chakraborty
Nipu Chakraborty

Posted on

Comma operator (,)

The comma operator (,) execute both operand but return only right side value

let num = 1;

num = (num++, num);

console.log(num);
// expected output: 2

x = (2, 3);

console.log(x);
//expected output: 3
Enter fullscreen mode Exit fullscreen mode

Top comments (0)