我有一个变量如下:
var dataset = {
"towns": [
["Aladağ", "Adana", [35.4,37.5], [0]],
["Ceyhan", "Adana", [35.8,37], [0]],
["Feke", "Adana", [35.9,37.8], [0]]
]
};
该变量中有很多城镇数据。如何有效地从数据中提取第三个元素的第一个元素?我,e,...
下面会是什么?
var myArray = ...
//myArray == [35.4,35.8,35.9] for the given data
如果我想将两个值都存储在数组中该怎么办?那是
var myArray = ...
//myArray == [[35.4,37.5], [35.8,37], [35.9,37.8]] for the given data
我对 Javascript 很陌生。我希望有一种不使用 for 循环的方法。