2013/3/17 Andrea Giammarchi <[email protected]>
> There are many cases where changing runtime prototype, mutating, dropping,
> whatever, can be used and it would be cool to secure nobody can retrieve it
> outside the private scope.
>
So basically you want to give a third party an object which has a prototype
that you want to be able to mutate, but you want to prevent the other party
from mutating it? That sounds like a Proxy.
var Public = (function () {
var Private = {
foo: 'bar'
};
var proxy = new Proxy(Private, {
set: function () {
// do nothing
}
});
return Object.create(proxy);
}());
console.log(Public.foo); // 'bar'
Object.getPrototypeOf(Public).foo = 123;
console.log(Public.foo); // 'bar'
Juan
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss