Open perguth opened 8 years ago
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.
At least I would like to read more on that topic touched upon in the
constructor tip
in the reusable compontens section.