这段代码意味着什么? (JavaScript)的 [英] What does this piece of code means? (Javascript)
本文介绍了这段代码意味着什么? (JavaScript)的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var chatRoom = {
'all': []
};
我是编程新手,我必须经历一些代码。我有一些Java知识,但不是JavaScript。请原谅我提出愚蠢的问题。谢谢!
我的尝试:
没什么尝试。我只需要一些解释。
I'm absolutely new to programming and I have to go through some code. I've some knowledge of Java, but not JavaScript. Pardon me for asking silly questions. Thank you!
What I have tried:
Nothing much to try. I just need some explanation.
推荐答案
它是JSON,它创建了一个名为chatRoom的对象,其中包含一个名为all的属性,该属性的值为[],这意味着一个空数组。所以一旦定义你可以操作数组作为普通的js数组
It's JSON and it creates an object called chatRoom with a property called "all" and the value of that property is [] which means an empty array. So once defined you can manipulate the array as a normal js array
var chatRoom = {
'all': []
};
chatRoom.all.push('Hello');
chatRoom.all.push('World');
for (var i = 0; i < chatRoom.all.length; i++)
{
alert(chatRoom.all[i]);
}
请参阅 JavaScript教程 [ ^ ]。
>
这篇关于这段代码意味着什么? (JavaScript)的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文