Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
duplicate same elements in an array in javascript

I want to duplicate array with same elements that contains the first array For example, I have this array

let array1 = [{title: "test1"}, {title: "Test2"}, {title: "test3"}];

I need to transform it into

array1 = [{title: "test1"}, {title: "Test2"}, {title: "test3"}, {title: "test1"}, {title: "Test2"}, {title: "test3"}];

Thanks a lot.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

try to concat, like:

let array1 = [{title: "test1"}, {title: "Test2"}, {title: "test3"}];

array1 = array1.concat(array1);
about 4 years ago · Juan Pablo Isaza Denunciar

0

I am not sure what you are trying to achieve, but here's a solution.

let array1 = [{title: "test1"}, {title: "Test2"}, {title: "test3"}];  
array1 = [ ...array1, ...array1]
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can also achieve it with a little for loop :)

let arr = [1, 2, 3] ;
let new_array = [] ;
for(let i = 0 ; i < 2 ; i++) {
    new_array = new_array.concat(arr) ;
}

console.log(new_array) ;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda