with({}) { if (foo) { console.log("foo"); // fails foo is not defined. } } with({}) { if (typeof foo !== "undefined") { console.log("foo"); // no error } }