简体   繁体   中英

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.

这是0的数组个元素也就是0的个元素line0 ,所以:

line0[0][0]

这是代码:

var date = line0[0][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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM