Line:
var bar = new Object( foo );
It does nothing in your first fragment - you are right with your assumption, it will simply return a reference to the same object passed to the Object constructor.
This behavior is when you pass your own object to the Object constructor in the expression new ( new Object(value) ), if you pass the object to the host object , the results are implementation dependent.
If you do not pass a value (or explicitly pass undefined or null primitives), a new object will be created that inherits from Object.prototype .
Otherwise, if you pass any of the remaining primitives (like Number, String, or Boolean value), a primitive wrapper object will be created (basically a primitive-object type conversion).
var s = new String("foo");
See this question about primitives and objects: How is a Javascript string not an object?
In your second snippet, line:
var bar = Object.create( foo );
Creates a new object that inherits from foo , and since it is a different object when you assign properties:
bar.three = 3; bar.one = 100;
Those will be created physically on this separate instance, as you can see, in bar.one shadow property is the value contained in foo .
The object referenced by bar will actually contain two properties of its own ( one and three ), but since it inherits from foo , a property called two resolvable through a prototype chain, for example:
bar.hasOwnProperty('one'); // true, the property is "own" bar.hasOwnProperty('two'); // false, the property is "inherited" from foo bar.two; // 2, is accessible
In principle, the bar prototype chain looks like this:
-----------------
=========> | Object.prototype | ==> null
| -----------------
| ------------- | [[Prototype]] | --------- |
| one: 100 | ======================> | one: 1 | (shadowed)
| three: 3 | | two: 2 |
| ------------- | | --------- |
(== line denotes the prototype chain)