Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jashkenas/3836156 to your computer and use it in GitHub Desktop.
Save jashkenas/3836156 to your computer and use it in GitHub Desktop.
for (key in this.attrs) {
this[key] = function() {
return this.attrs[key];
};
}
@al6x
Copy link

al6x commented Oct 5, 2012

What if list of attributes unknown beforehand or changing over time?

obj.attrs.newAttribute = 'hello'
obj.newAttribute() => TypeError: undefined is not a function

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