Javascript - Operator Comma Operator

Introduction

The comma operator can execute more than one operation in a single statement:

var num1=1, num2=2, num3=3;

The comma operator above is used in the declaration of variables.

You can use it to assign values. In this way, the comma operator always returns the last item in the expression:

var num = (5, 1, 4, 8, 0);  //num becomes 0

In this example, num is assigned the value of 0 because it is the last item in the expression.