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

112
Vistas
Save a changing variable in javascript

In my code I want to save an object that changes during the execution in an array inorder to use it after the execution of the function,so I tried to create a copy of it using this approach:

let copy=[...original]//original is the variable that changes during the execution when I used this approach I noticed that the content of the copied array is the same as the last value of the original array. Now I need a method that can keep all the states of the original array in one variable.

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

0

You can give a try to structuredClone() method which help you in creating a deep clone of a given value using the structured clone algorithm.

// Create an object with a value
const original = { name: "Alpha" };

// Clone it
const clone = structuredClone(original);

// Change original object value in execution
original.name = 'Beta';

console.log(original); // { "name": "Beta" }
console.log(clone); // { "name": "Alpha" }
console.log(clone !== original); // true

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