with (context) + eval = user-space lexical environment ?
context = { foo: 1, bar: 2 };
with (context) {
foo = 2;
bar = 3;
}
That will probably do what you expect. But now say you run it where context is just ... context = { foo: 1 };
with (context) {
foo = 2;
bar = 3;
}
... you might think this would add a 'bar' property to your context object, but in fact it creates a global variable bar. Whoops!In short, 'with' is pointy on both ends.
If you're needing with and have access to npm, use contextify, It'll save you a lot of effort!
[1] I just finished skimming through eloquent js and js allonge, and this still eluded me.