javascript - Get Data from Array Without Quotes
问题描述
I having a problem with an array inside a JavaScript, and I don't how I can get the data from inside the array. This is the code:
array = [A(-11.8,166.88),A(-11.8,166.88),A(-11.8,166.88)]
function A(a,b) {
polyCoords.push(projTransform(a,b));
}
I want to get each lat and long separate in javascript format, but I don't know how I can proceed. Probably is more easier than I think, but currently I block with this.
Do you have any idea on how can I proceed?
The result that I want is to obtain this data.
array[0] = [-11.8,166.88]
array[1] = [-11.8,166.88]
array[2] = [-11.8,166.88]
Thanks in advance
解决方案
var array = [A(-11.8,166.88),A(-11.8,166.88),A(-11.8,166.88)];
function A(a,b) {
//polyCoords.push(projTransform(a,b));
//you need to return a value, otherwise the result of the method
//is undefined
return [a, b];
}
console.log(array);
console.log(array[0][0], array[0][1]);
console.log(array[1][0], array[1][1]);
console.log(array[2][0], array[2][1]);
推荐阅读
- c++ - c++ 代码打印出带有数字和星号的三角形
- python - 如何从石榴高斯混合模型中获取均值和协方差值
- c# - C# await 后代码执行会继续吗?
- javascript - 有没有办法用javascript更好地显示数字?(带逗号等)
- flutter - 在 chart_flutter 小部件中使用 NumericEndPointsTickProviderSpec 呈现在图表外部的条形图
- python - 带有 UDF 的 PySpark 数据框
- r - R 基于两个索引列对两列中的值求和,留下 NA 值
- c# - ASP.NET MVC 在创建新用户时向表中添加另一条记录
- python - 在 Django 中通过 URL 传递列表时出错
- c# - 我正在尝试创建一个命令,使机器人 DM 在指定时间成为用户