Loop through Dictionary in JavaScript

by shraddhapaghdar

JavaScript

const object = {
  employeeName: "John Doe",
  employeeId: 27,
  salary: {
    "2018 - 19": "400000INR",
    "2019 - 20": "500000INR",
    "2020 - 21": "650000INR"
  },
}


Object.defineProperty(object, 'address', {
  value: "India",
  configurable: true,
  writable: false,
  enumerable: false,
});

for (const [key, value] of Object.entries(object)) {
  console.log(key, value);
}