Ever wanted to know if an object is an empty object (equivalent to {})? Those new to JS often mistakenly assume that {} == {} but not so.
This function simply tries to iterate the object, returning true on the first iteration or false if the object has no properties to iterate.
Use cases include the following:
- Performing an ajax request on "finish" only if the cache contains actions to perform
- Prompting user to save on page unload only if actions have been taken
- Showing an object as an ordered list or select options
One could argue that $H(object).size() == 0 performs the same function, but it is less intuitive and time-consuming for large objects.