InterviewHubPRO
Section Overview
Q254

Question 254 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

49%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

What is the comma operator

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
  var x = 1;
  x = (x++, x);

  console.log(x); // 2