首页 > 解决方案 > 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

标签: javascriptarrays

解决方案


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]);


推荐阅读