Skip to content

Instantly share code, notes, and snippets.

@isao
Created October 5, 2012 19:20
Show Gist options
  • Save isao/3841808 to your computer and use it in GitHub Desktop.
Save isao/3841808 to your computer and use it in GitHub Desktop.
extend eventemitter w/ Object.create and mixin
var Event = require('events').EventEmitter;
function Person(name) {
this.name = name
}
function getname() {
return this.name
}
Person.prototype = Object.create(Event.prototype, {
getname: {
value: getname
}
});
@isao
Copy link
Author

isao commented Oct 5, 2012

var i = new P('imy')
i.nom();
// 'imy'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment