0

I have viewed a strange syntax in JS. I don't know what is this. I have tested a simple ex in browser console. The code below:

const x = [1,2,3];
(x[0]+=1,x) // [2,2,3]
  • This is using [Comma operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator). It is incrementing the `0` index and returning the array `x` as the value of the expression. – adiga Sep 28 '20 at 05:55

0 Answers0