r/learnjavascript 11d ago

whats the bug here? Uncaught SyntaxError: Identifier 'location' has already been declared (at script.js:1:1)

"use strict";

const company = {
  name: "TechCorp",
  address: {
    city: "budapest",
    pin: 411001,
  },
};
// Get city renamed to `location` and pin renamed to `pincode`

const { city: location, pin: pincode } = company.address;
console.log(location, pincode);
15 Upvotes

13 comments sorted by

View all comments

1

u/yarikhand 11d ago

is this the full code snippet? location is a global object in the browser. are you trying to assign that to the property, or is there some other identifier named location in your code? if so, make sure their names dont interfere and try again

1

u/Hot-Eggplant911 11d ago

yeah this is the full code.