comma operator (,)

JSstatementexpressionoperatorbinary ⟩ comma (,)

(operator)

<expr1>, <expr2>    // both expressions evaluated, last returned.
// ⭐️ expressions can't be declarations❗️

',' punctuator used in declaration syntax and comma operator.

for(let i=0, j=10; i < j; i++, j-- ) { ... }
//  ╰──── 1 ────╯         ╰── 2 ──╯
// 1. let declaration
// 2. comma operator

Last updated