I'm looking through the following code of what I assume could be called a jquery plugin:
H5P.Summary = (function ($, Question) {
function Summary(options, contentId, contentData) {
if (!(this instanceof H5P.Summary)) {
return new H5P.Summary(options, contentId);
}
It seems to create a Summary object but checks if it is an instance of itself first. Could someone please explain to me why it does this and what the purpose of the return statement is?
Source code on github:
https://github.com/h5p/h5p-summary/blob/master/js/summary.js#L3
The plugin itself:
I'm still fairly new to the web dev space, so corrections and simple explanations are welcome.