The object of the with can have properties that collide with local variables, it can drastically change the meaning of your program :
with (foo) { var x = 3; return x; }
The local variable x could be clobbered by a property of foo and perhaps it even has a setter, in which case assigning 3 could cause lots of other code to execute.
Therefore, 'with' statement should never be used. Instead, the previous code should be refactored to make direct calls to the object (foo.x
in the previous example).
What's more, using the 'with' statement would produce an error in JavaScript strict mode code.