Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to access the data in the second array from the following code:

var data = [ ["Team 1", 3], ["Team 2", 6], ["Team 3", 9]];

I am trying to access the "team" and "team number" using the following functions.

_Chart._accessors = {
`"team": function(data) { return data[0]; },`
`"current": function(data) { return data[0]; }`    
};

When I check the console log team, and current return arrays of two items which is logical.

My question is how do I access the data inside those arrays?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
230 views
Welcome To Ask or Share your Answers For Others

1 Answer

The same way as you access the data in the outside of them.

Stick [index] on the end of the thing you use to access them.

data[0][0] // for example
Chart._accessors.team()[0] // for another example

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...