简体   繁体   English

Javascript - 如何将单独的单个阵列组合到单个阵列?

[英]Javascript - How to combine seperate individual array to single array?

Let's say I have 2 individual arrays that consists of lat and long values respectively.假设我有 2 个单独的 arrays 分别由 lat 和 long 值组成。

lat = [23,34,25];
long = [11,12,13];

My question is how do i create output of combined lat and long arrays above to:我的问题是我如何创建 output 组合的经纬 arrays 到:

combined_latlong = [ [23,11] , [32,12], [25,13] ];

You can use map()您可以使用地图()

 const lat = [23, 34, 25]; const long = [11, 12, 13]; const result = lat.map((l, i) => [l, long[i]]); console.log(result);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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