Use the map
method:
var a = [1, 2, 3]
var b = ['a', 'b', 'c']
var c = a.map(function(e, i) {
return [e, b[i]];
});
console.log(c)
More Related Contents:
- Filter JSON by key value with JavaScript
- compare each 5 numbers of two array [closed]
- fetch first element of every string in array using javascript [closed]
- Convert string into several integer arrays [duplicate]
- Accesing 2d arrays from Javascript [closed]
- Best way to find if an item is in a JavaScript array? [duplicate]
- Most efficient way to create a zero filled JavaScript array?
- Sort array of objects by single key with date value
- How to group by and sum an array of objects? [duplicate]
- Group objects by multiple properties in array then sum up their values
- What is “undefined x 1” in JavaScript?
- Check if an array is empty or exists
- Why Array.indexOf doesn’t find identical looking objects
- JavaScript – populate drop down list with array
- Explanation of [].slice.call in javascript?
- Sorting objects by property values
- How to filter an array in javascript?
- Get unique results from JSON array using jQuery
- Compare 2 arrays which returns difference
- Getting a list of associative array keys
- How to find duplicate values in a JavaScript array of objects, and output only unique values?
- How much faster are arrays than accessing Google Sheets cells within Google Scripts?
- Getting index of an array’s element based on its properties
- Javascript remove all occurrence of duplicate element, leaving the only one that is unique
- JavaScript: Remove duplicates of objects sharing same property value
- JavaScript filter array by data from another
- What is the difference between “in operator” and “includes()” for JavaScript arrays
- How do I unset an element in an array in javascript?
- javascript – match string against the array of regular expressions
- How to find the coordinate that is closest to the point of origin?