So I was digging through repairES5.js
http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/ses/repairES5.js#1427
and noticed that:
var a = Object.freeze({ 'x': 1 });
var b = Object.create(a);
b.x = 2;
b.x; // should still be 1
Then I dug into spec and noticed:
http://es5.github.com/#x8.12.4
so `b.x` remains 1 because the property 'x' of its [[Prototype]] is
writable: false.
Ok, so why all of that when you could simply do:
var b = Object.create(a, {
'x': {
'configurable': true,
'enumerable': true,
'writable': true,
'value': 2
}
});
or
Object.defineProperty(b, 'x', {
'configurable': true,
'enumerable': true,
'writable': true,
'value': 2
});
b.x; // 2
- JDD
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss