browserify-handbook
browserify-handbook copied to clipboard
"constructor tip" references?
At least I would like to read more on that topic touched upon in the constructor tip in the reusable compontens section.
It's to do with checking that the context, this, is an instance of the object Widget, ie. called with new. You can read more about what the new keyword does here 😄 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new
Another point worth noting is that if nothing is returned for the constructor, the newly created object is returned. This means you can freely choose to return something else if you want to. However this is rarely seen, but applicable in some special cases.