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

178
Vistas
How to create a new array with the same content?

I use an external library to iterate over the array. It has the next() function to go to the next array item and returns false if there is no next item. If the next() is called the first time, then it returns the first item.

But here is how it works -

var a = ['item1'];
a.next(); // 'item1' is returned
...
a = ['item1']; // it could be called several times
a.next(); // false is returned, but 'item1' is expected

Is there any way to make a array to be treated as new array by next() function? I tried to add new elements to a (a.push(' ')) and it works well, but then I have to deal with an empty array elements.

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

0

If it's a one dimensional array you could probably do something like:

let newArray = [...oldArray];

This would create a new array.

Can I ask you why you are using an external library to map over an array?

about 4 years ago · Juan Pablo Isaza Denunciar

0

You could use the spread operator to create a shallow copy of that array.

var a = [1,2,3];
var b = [...a];

a.push(4);

console.log("a = " + a);
console.log("b = " + b);

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