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.