Can somebody explain what is going on here: code sample 1:
o2={b:10};
function classCreate(proto,o){
return Object.create(proto,o);
}
var o1=classCreate({a:o2},{});
console.log(o1.a.b); // prints 10
code sample 2:
o2={b:10};
function classCreate(proto,o){
return Object.create(proto,o);
}
var o1=classCreate({},{a:o2});
console.log(o1.a.b); //reference error
How does Object.create manage to mangle its scope when extending the final object?