} // Make the module a reference to the constructor. module.exports = AsyncAttendee; // "private" methods take context as the zeroth argument. function sayHello(asyncAttendee) { return 'Hello ' + asyncAttendee.name + '!'; } AsyncAttendee.prototype.hello = function () { console.log(sayHello(this)); };
Make the module a reference to the constructor. module.exports = AsyncAttendee; // "private" methods are prefixed with _ . AsyncAttendee.prototype._sayHello = function () { return 'Hello ' + this.name + '!'; }; AsyncAttendee.prototype.hello = function () { console.log(this.sayHello()); };