V
V
vasIvas2014-12-08 15:20:26
Node.js
vasIvas, 2014-12-08 15:20:26

How do you declare variables in nodejs?

In pure js, it is customary to declare properties separated by commas with one declaration statement -

var a = 0,
  b = 1,
  c = 3;

But on githab I see very often when properties are declared like in below code -
var a = 0;
var b = 1;
var c = 2;

I could not find the convention, so I ask - how is it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-12-08
@vasIvas

And as you wish. I like the first option, but it has one unpleasant minus - in git logs, adding a variable will affect two lines and not one:

var a,
      b;

var a,
-     b;
+     b,
+     c;

The second option is more pleasant from this point of view. So decide what is more important to you. Beautiful logs or nice-looking code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question