What are the differences between using Object.assign and class/extends?
<p>I am trying to understand how Facebook Flux works by looking at the source code of their <a href="https://github.com/facebook/flux/tree/master/examples/flux-chat" rel="nofollow">flux chat example</a>.</p>

<p>There, I saw <a href="https://github.com/facebook/flux/blob/master/examples/flux-chat/js/stores/MessageStore.js#L44-L94" rel="nofollow">this code</a>:</p>

<pre><code>var MessageStore = assign({}, EventEmitter.prototype, {

  emitChange: function() {
    this.emit(CHANGE_EVENT);
  },

  /**
   * @param {function} callback
   */
  addChangeListener: function(callback) {
    this.on(CHANGE_EVENT, callback);
  },
  ...
}

...

module.exports = MessageStore;
</code></pre>

<p>...where assign is just polyfilled Object.assign from ES6 spec.</p>

<p>Hm. Would this code, using classes and extends instead, work? Would it mean the same thing? What are differences and advantages/disadvantages of this approach?</p>

<pre><code>class MessageStore extends EventEmitter {
    emitChange() {
        this.emit(CHANGE_EVENT);
    }

    addChangeListener(callback) {
        this.on(CHANGE_EVENT, callback);
    }

    ...
}

module.exports = new MessageStore();
</code></pre>

<p>I am asking, because, coming from other languages, I intuitively understand class/extends, while prototype-based inheritance is always a little unclear to me.</p>