title: Javascript closure: difference between accessing the model directly and using a variable
body: <p>I've noticed that this code does not work as I expected.</p>
  
  <p>Message RENDER_IMAGE is broadcasted multiple times with different image in payload, but self.model.get("image") in code below always returns last image. Why? </p>
  
  <pre><code>bus.subscribe("RENDER_IMAGE", (message, payload) =&gt; {
      const self = this;
      self.model.set(payload);
  
      self.render().then(function() {
              bus.broadcast("IMAGE_RENDER_COMPLETE", self.model.get("image"));
          });
  });
  </code></pre>
  
  <p>Meanwhile this code works correct:</p>
  
  <pre><code>bus.subscribe("RENDER_IMAGE", (message, payload) =&gt; {
          const self = this;
          self.model.set(payload);
          const image = self.model.get("image"));
  
          self.render().then(function() {
                  bus.broadcast("IMAGE_RENDER_COMPLETE", image;
              });
      });
  </code></pre>