Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!