JS Coding Questions Logo
JS Coding Questions
#250💼 Interview💻 Code

What is the comma operator

Advertisement

728x90

The comma operator is used to evaluate each of its operands from left to right and returns the value of the last operand. This is totally different from comma usage within arrays, objects, and function arguments and parameters. For example, the usage for numeric expressions would be as below,

javascript
1var x = 1;
2
3x = (x++, x);
4
5console.log(x); // 2

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 79

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
250of476