Javascript: Checking if an object has no properties or if a map/associative-array is empty [duplicate]
Try this:
function isEmpty(map) { for(var key in map) { if (map.hasOwnProperty(key)) { return false; } } return true;}
Your solution works, too, but only if there is no library extending the Object
prototype. It may or may not be good enough.