JSFiddle - React, Tailwind, and code Playground
JavaScript
// ctor for foo object
function foo(callback) {
// do slow initialization here..
// callback when done
callback();
};
foo.prototype = function() {
return {
// doStuff method
doStuff: function() {
alert('stuff done');
}
};
}();
// instantiate the foo object, passing in the callback
var f = new foo(function() {
//Uncaught TypeError: Cannot call method 'doStuff' of undefined
f.doStuff();
});