OK, I really have read everything I can find trying to get a comprehensive understanding of Javascript. I know this can be done using a constructor function, but I’m trying to understand the language enough to know why this happens…
PeepClass = { color: "Yellow", shape: "Chick" };
var peepsA = new Object(PeepClass);
var peepsB = new Object(PeepClass);
if ( peepsA == peepsB )
document.write( "Why wouldn't these be unique instances?" );
Why doesn’t new Object(PeepClass) create unique instances of the PeepClass object? Instead, it results in three references to the same object.
I guess you want this:
Now
peepsAis a new object which inherits from the objectPeepClass.Btw when you pass an object into
new Object(), that same object is returned, ergo, the operation is a no-op.which means that the notation
new Object( obj )is meaningless.