Home  >  Q&A  >  body text

javascript - There is a problem when printing the newly composed array. There are objects in it, but the length is empty.

Array A (this.slots[0].values) is newly created in the A method,
For example:
this.slots[0].values.push(newValue)
Print after creation There is no problem in coming out:

Then use it in other methods, method B,
When printed, the array becomes:

Compared:

What is the problem? No operations were performed during this period

给我你的怀抱给我你的怀抱2662 days ago1130

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-07-05 10:51:48

    It may be a problem with this pointer, var self = this, and then try using self to do this

    reply
    0
  • Cancelreply