In JavaScript. How can I change a field of an object by changing a variable with a reference to that field?

  • 0
    I have an object, and I want to change some of its fields by changing another variable. How can this be done? My example code:
    var data = {
        a: 5
    var b = data.a
    b = 10
    JavaScript Anonymous, Mar 5, 2020

  • 1 Answers
  • 0
    In no way, assigning something to b, he forgets about the reference to the previous value

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!