You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Thinking through what an implementation of getPrototypeOf() or getClass() (='the function object') could entail, it may not be easily done... Shims or fillins do that by creating an extra instance variable and assign the constructor function - or class (function). Since it is in the constructor itself, it is nothing wrong to 'globally' reference it in there. Taking the same approach for referencing the constructor function - self in itself - and use the (now) available .bind(), simplifies above approach to this:

    function EasyVR(...) {
      ...
      this.ser.on('data',EasyVR.prototype.onWa­tch.bind(this));
     ...
    }
    

    @DrAzzy, renaming onWatch (vs. onTimeout) to onData would go in synch with serial.onData()... ;-)

About

Avatar for allObjects @allObjects started