Computer >> Computer tutorials >  >> Programming >> Javascript

What does a comma do in JavaScript expressions?


Comma is an operator in JavaScript, which returns the last operand while evaluating each of its operands.

Example

<!DOCTYPE html>
<html>
   <body>
      <script>
         var a = 100;

         a = (a++, a);
         document.write(a);

         a = (200, 300);
         document.write("<br>"+a);
      </script>
   </body>
</html>