title: arrays disappearing in method scope
body: <p>I am trying to create a class to my javascript game to add multiplayer but within the class i am having problems with the values of arrays changing as you can see in the <code>sendNetEntities()</code> function</p>
  <pre class="lang-js prettyprint-override"><code>class NET_IO{
      //probably put address here
      //I want to check for localhost to denote MASTER client
      constructor(host, netlayer){
          this.socket = io();
          this.netLayer = netlayer
          console.log(this.socket)
          this.netEntities = this.netLayer.entities
          //setInterval(() =&gt; {this.update()}, 200)
      }
  
      getNetEntities(){
          this.socket.emit('getNetEntities', (net_entities) =&gt; {
              console.log(net_entities)
              this.netEntities = net_entities
          })
      }
  
      sendNetEntities(layer){
          var netEnt = this.netEntities
          console.log(netEnt)                 //this returns [background: Entity, NIkTag: Entity, player: Entity]` the value i want
          var ent = JSON.stringify(netEnt);
          console.log(ent)                   //this returns [] 
          this.socket.emit('sendNetEntities', ent)
      }
  
      update(layer, callback){
          //check host if localhost dont retreive new data only send
          this.sendNetEntities(layer)    
          callback(this.netEntities)
  
  
      }
  }
  </code></pre>
  <p>I think im having problems with variables somehow being references of something instead of instances. But im not entirely sure all of the rules behind that for javascript. can anyone help me shed some light on this problem. I'm willing to edit my question as needed</p>
  <p><strong>EDIT</strong></p>
  <p>further debugging leads me to believe that it must be some sort of problem with socket.io. if i run this <code>this.socket.emit('sendNetEntities', {netEnt})</code> my return on the server is <code>{netEnt:[]}</code> I havent had problems like this in socket.io in the past. Am i doing something wrong. is socket.io the problem</p>