What does a comma do in JavaScript expressions?

JavascriptObject Oriented ProgrammingFront End Technology

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>
raja
Published on 27-Feb-2018 15:57:16
Advertisements