[英]declaring multiple variables in a single statement
Saw something akin to the following in a js snippet:在 js 片段中看到类似于以下内容的内容:
var aaa = "eeee" + "rrrrr", bbb = "qqqqq" + "tttttt";
I'm confused, what is the advantage of doing that vs just:我很困惑,这样做与仅这样做有什么好处:
var aaa = "eeee" + "rrrrr";
var bbb = "qqqqq" + "tttttt";
The comma, in this situation, allows you to declare multiple variables without having to re-use the var
keyword over and over again:在这种情况下,逗号允许您声明多个变量,而不必一遍又一遍地重复使用
var
关键字:
var variable1 = 'foo',
variable2 = 'bar';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.