Object and primitive type equality
I know that identical objects are not equal, i.e: var obj = { name: "Value" }; var obj2 = { name: "Value" }; console.log("obj equals obj2: " + (obj === obj2)); //evaluates to false Yet primitive types are: var str = "string1"; var str2 = "string1"; console.log("str equals str2: " + (str === str2)); //evaluates to true My question is why. Why are objects and primitives treated differently? If an object is nothing but an empty container, with only the attributes you specify to put in the container, why wouldn't the container's identical attributes evaluate to be the same? I looked around for