What is your preference in declaring multiple variables in JavaScript?
Combined declaration
const a = 1,
b = 2,
c = 3;
or Separate declaration
const a = 1;
const b = 2;
const c = 3;
The combined declaration is described in one-var rule in eslint as described here. However, eslint-airbnb config prefers separate declarations due to multiple reasons which seem to make sense.
I use and encourage 'Separate Declarations'.
Lucy Hill
Full Stack Developer
If find separate declarations easier to read.
I knew someone who would put them all on one line:
let a = 1, b = 3, x = 5, y = 10 etc...