title: Load JSON data into a JS class
body: <p>I'm using a modular approach for a JavaScript application: <code>Floor</code> is a subtype of <code>Tile</code>, and it has a lot of subtypes itself, but those are declared in JSON files, instead of other JavaScript classes.
  The thing is: To load a JSON file on the client side, I need to either do a synchronous request, which hurts performance, or an async one, which (apparently) doesn't let me put the data on the instance.</p>
  
  <pre><code>class Floor extends Tile {
      constructor(name) {
          $.getJSON('./data/tiles/floors/' + name + '.json', (json) =&gt; {
              let data = json;
  
              super(data.token, data.fg_color, data.bg_color, false);
  
              this.name = data.name;
              this.hardness = data.hardness;
              this.hitpoints = data.hitpoints;
              this.max_speed = data.max_speed;
              this.see_through = data.see_through;
              this.visible = data.visible;
              this.indestructible = this.hardness == -1 ? true : false;
          });
      }
  }
  </code></pre>
  
  <p>Is there a way to make this model work, or am I better using JavaScript classes for everything? I like this JSON approach a lot.</p>