0

Say I have this object:

info: {
   firstName: Joe,
   lastName: Smith,
   userName: jsmith
}

Then through a function I want to update just the userName within info because his userName is now jsmith1. How would I go about doing such a thing?

1 Answers1

1

info.userName = "jsmith1";

or...

info["userName"] = "jsmith1";

If you are interested in understanding JavaScript objects, read this

This answer also provides an explanation of when to use bracket notation vs. dot notation

maury844
  • 1,210
  • 15
  • 25