Skip to content

Instantly share code, notes, and snippets.

@AvianFlu
Created August 11, 2011 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AvianFlu/1139004 to your computer and use it in GitHub Desktop.
Save AvianFlu/1139004 to your computer and use it in GitHub Desktop.
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