I need to set all properties of some object to null
.
But the object can be very big, so I can\'t just do it one by one.
How to set all properties at onc
But the object can be very big, so I can't just do it one by one.
By "big" do you mean "millions of properties" and you are concerned about performance? Or do you mean "a bunch of properties you don't know the names of, and/or don't want to have list out"?
How to set all properties at once?
You can't. One way or another, you have to loop.
Instead of mutating an existing object, consider creating a new, empty object. Its property values will be undefined
, but that could work depending on your code structure.