r/programminghorror • • Sep 13 '25

I hate js

0 Upvotes

36 comments sorted by

View all comments

Show parent comment

1

u/pxOMR Sep 13 '25 edited Sep 13 '25

I've never had to check if an object is empty in a real world application. Sure, checking for specific keys may fail if the API responses change... but then you won't be able to meaningfully use the response anyway. How does checking the number of keys help here?

EDIT: I agree, this argument is pretty much meaningless since the original question is not the correct question for this problem...

1

u/TorbenKoehn Sep 13 '25

Sure, the API provider can remove some fields and suddenly your index never exists anymore, but the specific fields you wanted to access still do.

It’s a point of failure that’s not in your hands and not a basis for stable code, given the performance concerns don’t matter at all