Alex Mcp
Alex Mcp

Reputation: 19315

Confusion about assignment with commas

What is the logic behind the following code?

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.

Upvotes: 1

Views: 300

Answers (2)

Gabriel McAdams
Gabriel McAdams

Reputation: 58301

multiple variable declarations.

its the same as this:

var next;
var output = null;
var thisNode;

Upvotes: 3

jweber
jweber

Reputation: 589

It's just a shorter way of writing:

var next;
var output = null;
var thisNode;

Upvotes: 7

Related Questions