Javascript中多维数组的资源

时间:2012-02-09 19:35:25

标签: javascript arrays

我需要创建一个更有条理的数据数组来解析我的模板 我怎么能写得更好?我想将数组分组在他们自己的数组中,如Vars:[array],[array] ... mvData:[array],[array] ... etc ..

我希望能够使用vars.globalVars [2] / mvData.Revenue - etc ......

我还在学习数组 - 请看下面的内容。所有的数据都只是比喻..

vars = ['Game', 'Player', 'Social Stats'];
mvData = ['22,359', '16,235', '10,938', '5,305', '12,588', '6,583'];    
evoMetric = ['Registered Players', 'Started Missions', 'Objects Bought', 'Combats', 'Guerrilla Combats', 'Teams Created', 'Guerillas created'];
playerMetric = ['playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric'];
socialMetric = ['Invitations', 'Gifts', 'Combats', 'Comic', 'Trailer', 'Illustration', 'Mission', 'Levels'];

3 个答案:

答案 0 :(得分:1)

在Javascript中,您可以轻松创建复杂的数据结构。以下是有效对象

myObject = {"property1": "value1", 
            "property2": "value2", 
            "subobject": {"subproperty": "subvalue"},
            "aubarray": ["element1", "element2", {"innerobjectkey": "innerobjectvalue"}]};

答案 1 :(得分:0)

你可以这样做吗

var MyArray = ['some text',[second dimension array],[second dimension array,[third dimension array] ]];

答案 2 :(得分:0)

您可以将其构建为对象:

{
vars: ['Game', 'Player', 'Social Stats'],
mvData: ['22,359', '16,235', '10,938', '5,305', '12,588', '6,583'], 
evoMetric: ['Registered Players', 'Started Missions', 'Objects Bought', 'Combats', 'Guerrilla Combats', 'Teams Created', 'Guerillas created'],
playerMetric: ['playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric'],
socialMetric: ['Invitations', 'Gifts', 'Combats', 'Comic', 'Trailer', 'Illustration', 'Mission', 'Levels']
}