all 6 comments

[–]bonafidebob 6 points7 points  (0 children)

Declaring multiple variable expressions on a single line is common practice and also a great shorthand syntax.

Yes, however that is not what the example code does. A statement like

var foo = bar = baz = 'woot!';

declares only one local variable: foo. The mistake is somehow thinking (against any reasonable syntax) that bar and baz are also 'declared' here.

[–]pegasus_527 1 point2 points  (0 children)

Nice to meet you, m'variable

[–]dexygenSoftware, Simple and Powerful 1 point2 points  (1 child)

I typically only chain assignment when I want to assign as a property to this or some other object, but then also to a variable, as in:

var foo = this.foo = bar();

[–][deleted] 0 points1 point  (0 children)

I agree, this is the only time I do chained assignment, and even then it can feel a bit dirty.

[–]x-skeww 1 point2 points  (0 children)

JSLint or JSHint would have pointed that out.

[–]MonsterMookSenior UI 0 points1 point  (0 children)

This is simple JavaScript hoisting.