单个逗号分隔的变量声明和多个声明之间有什么区别? [英] What is the difference between a single comma-separated variable declaration, and multiple declarations?
本文介绍了单个逗号分隔的变量声明和多个声明之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
逗号分隔声明有什么区别?
What is the difference between comma separated declaration:
var a=0, b=0, c=0;
和多行声明:
var a=0;
var b=0;
var c=0;
代码性能是否有差异?
推荐答案
以逗号分隔的声明只是简写.执行方面没有区别.但是,如果您声明了很多变量,它可以帮助减小javascript文件的大小.
The comma separated declaration is just a short hand. Executing-wise there's no difference. But it can help reduce the size of your javascript file if you are declaring a lot of variables.
您甚至可以:
var a = 1, b = 'string', c = new Date();
这篇关于单个逗号分隔的变量声明和多个声明之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文