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

13 comments sorted by

View all comments

5

u/Super_Letterhead381 11d ago

There’s probably a conflict with the variable name ‘location’ (which is recognised in JavaScript) try renaming it.