Monday, June 3, 2024
40
rated 0 times [  46] [ 6]  / answers: 1 / hits: 40135  / 8 Years ago, sat, october 29, 2016, 12:00:00

This is correct syntax:



let foo, bar;



This is incorrect



const foo, bar;



Why is that?



And is there a way to declare a number of constants in one place, and define them in another? Apart from bound declaration & definition.


More From » ecmascript-6

 Answers
17

Because a const declaration has to be initialized as well. This will work:



const foo = 1, bar = 2;

[#60243] Wednesday, October 26, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josefn

Total Points: 251
Total Questions: 93
Total Answers: 84

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;