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.

2

3 Answers 3

4

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

line0[0][0]
Sign up to request clarification or add additional context in comments.

Comments

0

Here is the code:

var date = line0[0][0];

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.