Comma Operator Javascript

Comma Operator

 Comma Operator return the value of the last operand , Comma operator evaluates each of it operator from left to right . For Example we will take a variable and assing comma operator as below


  var test = (1,2);
 
  console.log(test)
 
 
  when the following is executed in the output will be 2 , here it evalutes the operand from left to right and return the last value
 
  var x= 3;
  var test1 = (x++,x)
  console.log(test1)
 
 
  what happen when we pass multiple values with comma separated
 
 
  var test3 =(1,2,3,4,5,6,6,7,7,7,8,9)
 
  console.log(test3)
 
  What is the output here?

Comments