i've recently discovered that i can use ,
(comma) instead of declaring the variable properly like const num1
, when in a chain mode, what i want to know is if there is any side effects in using it?
the std way =>
const num1 = 1
const num2 = 2
const num3 = 3
The , way =>
const num1 = 1
, num2 = 2
, num3 = 3
! the console shows no syntax error on both of them !
There's actually no difference, as long as you know that the comma syntax keeps the kind of variable (block scoping, constant) the same all the way through. So this:
const num1 = 1;
const num2 = 2;
const num3 = 3;
Is exactly the same as this:
const num1 = 1,
num2 = 2,
num3 = 3;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With