以下声明是什么意思?
var line = {}, lines = [], hasmore;
我知道lines = []
是一个数组,但我不了解其他数据。
实际代码是使用javascript xpcom
逐行读取文件var line = {}, lines = [], hasmore;
do {
hasmore = istream.readLine(line);
lines.push(line.value);
} while(hasmore);
答案 0 :(得分:4)
它正在创建3个变量
var line = {}; // creates an object
var lines = []; // creates an array
var hasmore; // undefined
答案 1 :(得分:1)
声明了3个变量(参见:Declaring Multiple Variables in JavaScript)。
var line = {} // creates an empty object literal
lines = [] // creates an empty array literal
hasmore // creates an empty undefined variable, which can hold any datatype
答案 2 :(得分:0)
继续在您的控制台上尝试:
var line = {}, lines = [], hasmore;
然后访问它们你会看到:
line is Object,
lines is an array
hasmore is undefined