Javascript: Checking if an object has no properties or if a map/associative-array is empty [duplicate]
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: How do I test for an empty Javascript object from JSON? Is there an easy way to check if an object has no properties, in Javascript? Or in other words, an easy way to check if a map/associative array is empty? For example, let's say you had the following: var nothingHere = {}; var somethingHere = {foo: "bar"}; Is there an easy way to tell which one is "empty"? The only thing I can think of is something like this