What is the most efficient way of merging [1,2] and [7,8] into [[1,7], [2,8]]

前端 未结 4 1780
囚心锁ツ
囚心锁ツ 2021-01-13 15:43

Given 2 arrays [1,2] and [7,8] what is the most efficient way of merging that to form [[1,7], [2,8]]. I know we can do this:

a1 = [1,2], a2 = [7,8], a3=[];
f         


        
4条回答
  •  忘掉有多难
    2021-01-13 16:14

    You are basically searching for a function identical to Python's zip function, so check out the answers to an older SO question:

    Javascript equivalent of Python's zip function

提交回复
热议问题