[英]If I have a multidimentional array, how can I acsess only the first value of the first dimention?
If I have a multidimentional array, how can I acsess only the first value of the first dimention. 如果我有一个多维数组,如何只访问第一个维的第一个值。 I will Explain:
我会解释:
sampleArray=new Array[];
sampleArray[0]=["Nouns","Adjectives","Verbs"];
sampleArray[1]=["Colors","Time","Sound];
sampleArray[0][0]=["Person","Place","Thing"]
I would just like to get the word Nouns
but when I try to get the value of sampleArray[0][0]
it will just result Person, Place, Thing
! 我只想得到
Nouns
但是当我尝试获取sampleArray[0][0]
的值时,它只会导致Person, Place, Thing
!
In your sample code "Nouns" is actually located at 在示例代码中,“名词”实际上位于
sampleArray[0][0]
However you are replacing that with 但是,您将其替换为
sampleArray[0][0]=["Person","Place","Thing"]
Perhaps it would be easier to keep your information in an object. 将信息保存在一个对象中也许会更容易。 Then reference them that way.
然后以这种方式引用它们。 Not sure what your end goal is though so that may not work for you.
不确定您的最终目标是什么,因此可能对您不起作用。
var partsOfSpeach = {};
var noun = {};
noun.name = "Noun";
noun.def = ["Person","Place","Thing"];
partsOfSpeach.Noun = noun;
Then you can access the info at 然后您可以在以下位置访问信息
trace(partsOfSpeach.Noun.name); // "Noun"
trace(partsOfSpeach.Noun.def); // "Person","Place","Thing"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.