Right, that capture-in-prototype case does not differ due to both
cascade desugaring and 'with' searching the head object including its
prototype chain.
But with a deeper scope chain, and bar not bound in the innermost scope,
then 'with' allows an evil interloping function to shadow (or delete if
configurable) along the scope chain.
/be
David Herman wrote:
On May 31, 2012, at 9:50 PM, David Herman wrote:
Whereas with cascades, you'd get:
var obj = {
log: console.log.bind(console),
foo: function() { Object.prototype.bar = "captured" }
};
var bar = "local variable";
with (obj) {
log(bar); // local variable
foo();
log(bar); // local variable
}
Oh for crying out loud. Of course I meant:
var obj = {
log: console.log.bind(console),
foo: function() { Object.prototype.bar = "captured" }
};
var bar = "local variable";
obj.{
log(bar); // local variable
foo();
log(bar); // captured
}
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss