“Combine 2 matrizes JavaScript” Respostas de código

Combine duas matrizes JavaScript

let arr1 = [0, 1, 2];
let arr2 = [3, 5, 7];
let primes = arr1.concat(arr2);

// > [0, 1, 2, 3, 5, 7]
Arab Fire Shaman

JavaScript Combine matriz de matrizes

/* Flatten (merge) an array of arrays with reduce & concat */
let myArrays = [[1, 2, 3], [4, 5], [6]];
myArrays.reduce((initial, current) => initial.concat(current), []);
// → [1, 2, 3, 4, 5, 6]


/* Join multiple arrays together. */
let warm = ["red", "orange"];
let cool = ["blue", "purple"];
let neutral = ["brown", "gray"];
let colors = warm.concat(cool).concat(neutral);
// → ["red", "orange", "blue", "purple", "brown", "gray"]
Intra

Junte -se a duas matrizes em JS

const array1 = ["Vijendra","Singh"];
const array2 = ["Singh", "Shakya"];
const array3 = [...array1, ...array2];
// [ "Vijendra", "Singh", "Singh", "Shakya" ]
Anxious Alligator

Concatenar várias matrizes JavaScript

const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = [...array1, ...array2];

console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
Poor Pintail

Combine 2 matrizes JavaScript

//ES6 using the spread operator
const itemsA = [ 'Lightsaber', 'Mockingjay pin', 'Box of chocolates' ];
const itemsB = [ 'Ghost trap', 'The One Ring', 'DeLorean' ]
const allItems = [ ...itemsA, ...itemsB ];
Anthony Smith

mesclar matrizes em javascript

var array1 = ["Vijendra", "Singh"];
var array2 = ["Singh", "Shakya"];

console.log(array1.concat(array2));

Respostas semelhantes a “Combine 2 matrizes JavaScript”

Perguntas semelhantes a “Combine 2 matrizes JavaScript”

Mais respostas relacionadas para “Combine 2 matrizes JavaScript” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código