开发者

In JS/JQuery can I pull a single element out of a Multi-Dimensional array and store it in another array?

I am using flot to do some graphing and I am trying to animate the graph into steps. I want to take a multi-dimensional array with say 3 objects where each of those objects has 3 objects. So I have this:

array1[0][0] = 30

array1[0][1] = 30

array1[0][2] = 10

array1[1][0] = 35

array1[1][1] = 35

array1[1][2] = 15

array1[2][0] = 40

array1[2][1] = 40

ar开发者_如何学Goray1[2][2] = 20

Array1[1] is the second step of my graph (in this case drawing a circle starting at midpoint 35,35 with a radius of 15). My problem is I only want to send flot the current step. So I want to pull out the object stored in array1[1] and put it into another, blank array so I end up with array2 like this:

array2[0][0] = 35

array2[0][1] = 35

array2[0][2] = 15

I keep seeing a lot of information about copying whole arrays but I really just need the one part and I just can't figure it out. I'm sure I've just gotten too much in my own head but any help would be appreciated.


Javascript does not support true multi-dimensional arrays; you're using an array of arrays.

You can assign the inner array like this:

array2[0] = array1[0];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜