Skip to main content
edited tags
Link
Sampath
  • 66.2k
  • 70
  • 326
  • 461

Determning Determining if all attributes on a javascript object are null or thean empty string

Source Link
J-bob
  • 9.2k
  • 13
  • 57
  • 92

Determning if all attributes on a javascript object are null or the empty string

What is the most elegant way to determine if all attributes in a javascript object are either null or the empty string? It should work for an arbitrary number of attributes.

{'a':null, 'b':''} //should return true for this object
{'a':1, 'b':''} //should return false for this object
{'a':0, 'b':1} //should return false
{'a':'', 'b':''} //should return true