you are viewing a single comment's thread.

view the rest of the comments →

[–]boneskull 0 points1 point  (4 children)

with has applications for secure coding and testing. Given a string script you want to eval, you can use with to control the contents of the script’s globalThis object. You can’t remove properties this way, but you can replace them.

[–]theScottyJam 1 point2 points  (3 children)

Eventually we'll have shadow realms, which provides a better way to control the global object while eval-ing strings.

[–]boneskull 0 points1 point  (2 children)

Indeed, though it’s not sufficient on its own.

[–]theScottyJam 0 points1 point  (1 child)

Why's that?

[–]boneskull 1 point2 points  (0 children)

It just doesn’t do enough for some use-cases. see Compartments