0

Can variables be declared on a single line e.g, var a, b, c, d, rather than var a, var b, var c, var d, on four separate line?

declaring variables

14th Feb 2017, 8:31 PM
rodwynnejones
rodwynnejones - avatar
5 Réponses
+ 4
yes
14th Feb 2017, 8:35 PM
Kawaii
Kawaii - avatar
+ 2
You can, but with coma as separator, you must put the keyword 'var' once.... You can do ( wich is equivalent ) var a; var b; var c; /* or */ var a, b, c;; ... and with affectation: var a; var b=42; var c; /* or */ var a, b=42, c;; // a and c are juste declared, not initialized
15th Feb 2017, 6:50 AM
visph
visph - avatar
+ 1
wow, thank you for a very quick reply.
14th Feb 2017, 8:37 PM
rodwynnejones
rodwynnejones - avatar
0
This is good to know!!
17th Feb 2017, 6:43 AM
Brandon Duckett
Brandon Duckett - avatar
- 1
you can make it like this var a, b, c, d;
15th Feb 2017, 11:35 AM
Ibrahim Shabak
Ibrahim Shabak - avatar