I'm trying to understand the pros/cons of deleting the keys of an object vs. assigning a new empty object.
a = {test: "test"}
// approach 1
a = {}
// approach 2
const keys = Object.getOwnPropertyNames(a)
for (let i = 0; i < keys.length; i++) {
delete a[keys[i]]
}
This can be extended to other data structures like arrays. In terms of safety, performance, memory leak, garbage collection - what route should I take? Thanks!