user2023359
user2023359

Reputation: 289

Javascript get value from array

If I have the following code in Javascript:

var line0 = [["2012-07-01",1.8182],["2012-08-01",1.4000],["2012-09-01",1.7500]]; 

How can I obtain the first date, which in this case is: "2012-07-01"

Thanks in advance.

Upvotes: 1

Views: 2929

Answers (3)

zurfyx
zurfyx

Reputation: 32767

You can do it like that:

<script type="text/javascript">
var line0 = [["2012-07-01",1.8182],["2012-08-01",1.4000],["2012-09-01",1.7500]];
alert(line0[0][0]);
</script>

Upvotes: 0

mcont
mcont

Reputation: 1922

Here is the code:

var date = line0[0][0];

Upvotes: 0

mellamokb
mellamokb

Reputation: 56769

It's the 0-th element of the array that is the 0-th element of line0, so:

line0[0][0]

Upvotes: 4

Related Questions