r/learnjavascript • • Aug 30 '26

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);
14 Upvotes

13 comments sorted by

View all comments

1

u/yarikhand Aug 30 '26

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/[deleted] Aug 30 '26

yeah this is the full code.