search

Home  >  Q&A  >  body text

javascript - In the for loop, when the loop variable i is pushed into an array, why is the result printed on the console like this?

Every result is the same after clicking on it, it is the final result. What is the reason?

过去多啦不再A梦过去多啦不再A梦2858 days ago753

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-05-19 10:18:51

    Because what you output is the data array, if the content of data is modified later, the object on the console will also change accordingly.

    reply
    0
  • PHPz

    PHPz2017-05-19 10:18:51

    Yes, the data in the console is real-time, and the output is current. You can save the historical status and then output it, otherwise you will see the final result

    reply
    0
  • Cancelreply