Skip to content

Instantly share code, notes, and snippets.

@j8
Created June 19, 2016 13:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j8/4e96470619c1d842913234060499aefe to your computer and use it in GitHub Desktop.
Save j8/4e96470619c1d842913234060499aefe to your computer and use it in GitHub Desktop.
#Node.js interview questions
#
# Node.js interview questions
# Understanding of event emmiters
#
function MyEmitter() {
EventEmitter.call(this);
}
util.inherits(MyEmitter, EventEmitter);
MyEmitter.prototype.doStuff = function doStuff() {
console.log('before')
emitter.emit('fire')
console.log('after')}
};
var me = new MyEmitter();
me.on('fire', function() {
console.log('emit fired');
});
me.doStuff();
// Output:
// before
// emit fired
// after
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment