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
  • just do info.userName=jsmith1 Commented Jul 18, 2018 at 18:23

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.