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:
- Array.prototype.fill() with object passes reference and not new instance
- JavaScript: Difference between .forEach() and .map()
- Why can I add named properties to an array as if it were an object?
- How to extend an existing JavaScript array with another array, without creating a new array
- Is the order of elements in a JSON list preserved?
- JavaScript: How to join / combine two arrays to concatenate into one array?
- Maximum size of an Array in Javascript
- Sum JavaScript object propertyA values with the same object propertyB in an array of objects
- Merge 2 arrays of objects
- Convert string with commas to array
- How might I extract the property values of a JavaScript object into an array?
- Sampling a random subset from an array
- Create object from array
- Comparing two arrays of objects, and exclude the elements who match values into new array in JS
- How to check if a string array contains one string in JavaScript? [duplicate]
- Count duplicates within an Array of Objects
- MongoDB select where in array of _id?
- Search array of objects for entry matching variable and check if it matches other fields
- How can I perform an inner join with two object arrays in JavaScript?
- How to get the first element of an array?
- How to merge each object within arrays by index?
- Unexpected comma using map()
- Counting occurrences of particular property value in array of objects [duplicate]
- Sort a Javascript Array by frequency and then filter repeats
- How can I loop through enum values for display in radio buttons? [duplicate]
- Javascript array search and remove string?
- Using jQuery inArray with array of JavaScript Objects
- best way to generate empty 2D array
- Compare two Arrays with Objects and create new array with unmatched objects
- Why do these two javascript 2d-arrays behave differently?