I think it also makes sense in Python, where it can be used to automatically close a file, or
with open(filename) as my_file:
data = my_file.read()
Or with acquiring and releasing a lock:
lock = threading.Lock()
with lock:
pass # do stuff
That being said, I prefer the C++ approach of using constructors and destructors to automatically acquire resources (like locks and files) by declaring variables within some block scope, and release them once the scope is left.
or at least, it might be ... due to Javascript's dynamic and typeless nature you might not know for sure what will happen until runtime. Which is one reason it's now deprecated and not allowed in strict mode. In pascal, variables have a type, records have fields, and these are known at compile time so that's not an issue.
I knew about the Pascal "with", but I didn't know JavaScript had the same construct.
That kind of "with" is a lot less intuitive to me.
I was responding with Python's "with" because it sounded like they were talking about programming languages in general, but now I can see they were obviously talking about JavaScript's "with" given this context.