Declaring multiple variables in JavaScript

后端 未结 17 924
时光说笑
时光说笑 2020-11-22 13:16

In JavaScript, it is possible to declare multiple variables like this:

var variable1 = "Hello, World!";
var variable2 = "Testing...";
var          


        
17条回答
  •  独厮守ぢ
    2020-11-22 13:31

    The maintainability issue can be pretty easily overcome with a little formatting, like such:

    let
      my_var1 = 'foo',
      my_var2 = 'bar',
      my_var3 = 'baz'
    ;
    

    I use this formatting strictly as a matter of personal preference. I skip this format for single declarations, of course, or where it simply gums up the works.

提交回复
热议问题