loading...

re: How to Check if Object is Empty in JavaScript VIEW POST

FULL DISCUSSION
 

The real question is -- why would you ever want to check that an object is empty?

 

I've only used my isEmptyObj in sanitization code.
Cleaning out empty values from incoming data.

 

Hmm, I still can't figure out why you'd ever want to do that.

Surely you want to check the object for having some set of required and forbidden properties.

Checking for an empty object seems completely useless, because if you wanted an empty object you could just make one yourself.

And if you didn't want an empty object, that means that you want some object with some properties, in which case you can check for the properties that you want.

So, I still can't figure out why you'd ever want to check if an object is empty.

code of conduct - report abuse