Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created May 12, 2023 17:08
Show Gist options
  • Save suhailgupta03/2cb7f21a16ba4933cce5b255198cbd03 to your computer and use it in GitHub Desktop.
Save suhailgupta03/2cb7f21a16ba4933cce5b255198cbd03 to your computer and use it in GitHub Desktop.
const person = {
firstName: "..",
lastName: '..',
age: 30
}
console.log(person['age']);
// We want to modify the age
for(var nameOfKey in person) {
if(nameOfKey == "age") { // If the name of key is age
// If the key is age,
// then change the value of
// this key
person[nameOfKey] = 35;
}
}
console.log(person['age']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment