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

275
Vistas
How to delete object and all references?

We use the delete when we need to delete the object reference. But is there any way in JS to delete the entire object and all references?

Example:

let obj = {
    a: 3
}
let arr = [obj];
let brr = [obj];

If I'd change the obj items in the arrays would be changed too. Also, I can use delete arr[0] to delete the reference. But I want to delete the obj and I want the items in the arrays to be deleted too.

Something like:

// Before: 
let obj = {
   a: 3
}
let arr = [obj];
let brr = [obj];
arr.length==1 // true
brr.length==1 // true
// Deleting:
delete(obj)
// After:
arr.length==0 // true
brr.length==0 // true
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

No.

The only way to delete an object in JavaScript is to locate and delete each reference to it.

There's no generic mechanism to start with an object and automatically delete all references to it.

about 4 years ago · Santiago Trujillo 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