Javascript : async constructor pattern
I'm defining a class which instantiates several modules which depend on previous ones. The modules themselves may require an async operation before they are ready (i.e. establishing a mysql connection) so I've provided each constructor with a callback to be called once the module is ready. However I've run into a problem when instantiating classes which are ready immediately: var async = require('async'); var child = function(parent, cb) { var self = this; this.ready = false; this.isReady = function() { return self.ready; } /* This does not work, throws error below stating c1.isReady is