本文介绍了在javascript中创建和解析3D数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我在javascript中创建和解析3d数组。

can any one help me to create and parse a 3d array in javascript.

我有一个问题每个问题Id都有一个选定的选项和一个可选的选项文本。

im having a questionId each question Id have a selected option and an optional option text.

所以我需要为questionId,optionId,optionText(string)创建一个3d数组..

so i need to create a 3d array for questionId,optionId,optionText(string)..

Thnks提前

推荐答案

一维数组将是:

var myArr = new Array();
myArr[0] = "Hi";
myArr[1] = "there";
myArr[2] = "dude";

alert(myArr[1]);    // Alerts 'there'

二维数组将是:

var myArr = new Array();
myArr[0] = new Array("Val", "Va");
myArr[1] = new Array("Val", "yo");
myArr[2] = new Array("Val", "Val");

alert(myArr[1][1]); // Alerts 'yo'

3D数组更复杂,你应该评估你的建议用途因为它在网络中的范围有限。使用1D或2D阵列可以解决99%的问题。但3D阵列将是:

A 3D array is more complicated, and you should evaluate your proposed use of it as it has a limited scope within the web. 99% of problems can be solved with 1D or 2D arrays. But a 3D array would be:

var myArr = new Array();
myArr[0] = new Array();
myArr[0][0] = new Array()
myArr[0][0][0] = "Howdy";
myArr[0][0][1] = "pardner";

alert(myArr[0][0][1]); // Alerts 'pardner'

这篇关于在javascript中创建和解析3D数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 23:03