Is this valid JavaScript? I saw an example where someone used commas in the ternary operator conditions, and it was marked as an error in my editor, and the example didn\'t
Yes:
a=1; b=2; a!==b ? (a=1, b=2) : (a=2, b=1) console.log(a); // 1 console.log(b); // 2
and:
a=1; b=2; a===b ? (a=1, b=2) : (a=2, b=1) console.log(a); // 2 console.log(b); // 1
As you can analyze, changing the equality operator reacts correctly to our test if you look at the results.