Operator var abc = {}; creates a new (empty) object and points to the variable abc at this object.
The abc == {} test creates a second new (empty) object and checks if abc points to the same object. That it is not, therefore, false .
There is no built-in method (which I know) to determine if an object is empty, but you can write your own short function to do this as follows:
function isObjectEmpty(ob) { for (var prop in ob) if (ob.hasOwnProperty(prop)) return false; return true; }
(Checking hasOwnProperty() - ignore properties in the prototype chain not directly in the object.)
Note: the term “object” is what you want to use, not a “hash map”.
source share