views:

37

answers:

2

Can someone explain the potential logic behind a group assignment like this in javascript:

var next, output = null, thisNode;

It appears like it's some type of coalescing like var foo = bar || baz;, but I'm not so familiar with the commas. Thoughts?

+5  A: 

It's just a shorter way of writing:

var next;
var output = null;
var thisNode;
jweber
Just to emphasize for the OP: It's **exactly** the same as your rewritten version. Exactly, including the order (which can be important).
T.J. Crowder
+2  A: 

multiple variable declarations.

its the same as this:

var next;
var output = null;
var thisNode;
Gabriel McAdams