Skip to content

Instantly share code, notes, and snippets.

@westoque
Created April 26, 2012 23:05
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 westoque/2503983 to your computer and use it in GitHub Desktop.
Save westoque/2503983 to your computer and use it in GitHub Desktop.
var events = require('events');
function Dog() {
}
util.inherits(Dog, events.EventEmitter);
// This statement will override the current `prototype`, thus losing
// the methods from EventEmitter.
Dog.prototype = {
fetch: function() {
}
}
// This one will work though
Dog.prototype.fetch = function() {
}
// Question is, if my `Dog.prototype = {}` has lots of methods. I don't
// want to rewrite all of them to be like `Dog.prototype.METHOD_NAME`..
// how do I get around this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment