The with statement allows shorthand access to an object’s properties but is generally discouraged due to ambiguity in scope.
const obj = { name: "Bruce", city: "Gotham" };
with (obj) {
console.log(name, city); // "Bruce Gotham"
}
The with statement allows shorthand access to an object’s properties but is generally discouraged due to ambiguity in scope.
const obj = { name: "Bruce", city: "Gotham" };
with (obj) {
console.log(name, city); // "Bruce Gotham"
}