1

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.

Mosè Raguzzini
  • 15,399
  • 1
  • 31
  • 43
user2023359
  • 289
  • 2
  • 10
  • 18
  • 1
    Are you looking for line0[0][0]? – syazdani Jan 31 '13 at 20:57
  • possible duplicate of [I have a nested data structure / JSON, how can I access a specific value?](http://stackoverflow.com/questions/11922383/i-have-a-nested-data-structure-json-how-can-i-access-a-specific-value) – Felix Kling Jan 31 '13 at 20:59

3 Answers3

4

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

line0[0][0]
mellamokb
  • 56,094
  • 12
  • 110
  • 136
0

Here is the code:

var date = line0[0][0];
mcont
  • 1,749
  • 1
  • 22
  • 33
0

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>
zurfyx
  • 31,043
  • 20
  • 111
  • 145