I saw JavaScript code which begins with with
. That\'s a bit confusing. What does it do and how can it be used correctly?
with (sObj) return opti
the with
statement is pure syntactical sugar, but it also can cause some nasty bugs.
See with Statement Considered Harmful for clarification:
If you can't read a program and be confident that you know what it is going to do, you can’t have confidence that it is going to work correctly. For this reason, the
with
statement should be avoided.