Javascript statement allows shorthand access to an object’s properties

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"
}

Leave a comment

Your email address will not be published. Required fields are marked *