Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var Thing = module.exports = function (options) {
for (var o in options) {
this[o] = options[o];
}
}
Thing.prototype.method = function (arg) {
var self = this;
self.property = 'word';
fs.readFile('/root/something', function (err, data) {
console.log(self.property);
//self is still good here, who knows what 'this' might be.
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.