Declaring multiple variables in JavaScript

后端 未结 17 928
时光说笑
时光说笑 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:26

    I think it's a matter of personal preference. I prefer to do it in the following way:

       var /* Variables */
                me = this, that = scope,
                temp, tempUri, tempUrl,
                videoId = getQueryString()["id"],
                host = location.protocol + '//' + location.host,
                baseUrl = "localhost",
                str = "Visit W3Schools",
                n = str.search(/w3schools/i),
                x = 5,
                y = 6,
                z = x + y
       /* End Variables */;
    

提交回复
热议问题