browserify-handbook icon indicating copy to clipboard operation
browserify-handbook copied to clipboard

"constructor tip" references?

Open perguth opened this issue 10 years ago • 1 comments

At least I would like to read more on that topic touched upon in the constructor tip in the reusable compontens section.

perguth avatar Sep 10 '15 16:09 perguth

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.

emilbayes avatar Nov 08 '16 00:11 emilbayes