A
A
adrenalinruslan2019-05-04 10:17:11
JavaScript
adrenalinruslan, 2019-05-04 10:17:11

How to add to array?

In general, how to do so, to add to the array? I keep getting an error.

class Live {
  constructor()
  {
    this.users = [];
  }
  add(user)
  {
    if(typeof user.play !== 'undefined')
    {
      this.users.push({
        username : user.username,
        play : user.play,
      });
    }
  }
  get()
  {
    return this.users;
  }
}

When you call add(user) , you need to add an entry to the users array, but an error occurs. How to fix ?
I used to work in PHP, it works like that)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question