TIL JS commas evaluate operands
POSTED ON:
TAGS: javascript interview tricky
This is indeed some tricky Javascript.
var a=(2,3,4,5,6,7);
console.log(a); // 7
The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.
REFERENCE:
(Sometimes JavaScript is Tricky.)[https://dev.to/rajatarya007zxc/sometimes-javascript-is-tricky-67j]
Related TILs
Tagged: javascript