question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Advise against multiple assignment in var declaration

See original GitHub issue

I’d suggest to include a section in the guide explaining the scoping problems of this:

function foo() {
    var a = b = c = 1;
}

and to advise against it.

See http://stackoverflow.com/questions/1758576/multiple-left-hand-assignment-with-javascript

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anrddhcommented, Aug 17, 2016

@ljharb Ah, my bad. I didn’t notice that the rule works for this particular situation too. PR incoming ASAP!

0reactions
ljharbcommented, Aug 17, 2016

@awesomeaniruddh I believe http://eslint.org/docs/rules/one-var with the option “never” is the one I’m thinking of - we enable that here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Declaring multiple variables in JavaScript - Stack Overflow
The first way is easier to maintain. Each declaration is a single statement on a single line, so you can easily add, remove,...
Read more >
Multiple var statements in JavaScript, not superfluous
Assignments must be in their own var statement. Like this: // SIMPLE AND SEXY var foo, bar, baz; var abc = 1; var...
Read more >
DCL04-C. Do not declare more than one variable per ...
Declaring multiple variables in a single declaration makes sense if the rest of the code requires all these variables to have identical type....
Read more >
t sql - Assigning values to multiple @variables using SELECT
If there are multiple assignment clauses in a single SELECT statement, SQL Server does not guarantee the order of evaluation of the expressions....
Read more >
Multiple variables should not be declared on the same line
Declaring multiple variables on one line is difficult to read. Noncompliant Code Example. class MyClass { private int a, b; public void method(){...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found