Skip to content

Instantly share code, notes, and snippets.

@erming
Last active August 29, 2015 14:00
Show Gist options
  • Save erming/11196829 to your computer and use it in GitHub Desktop.
Save erming/11196829 to your computer and use it in GitHub Desktop.
lodash_model.js
var _ = require("lodash");
function Model(attr) {
_.merge(this, _.extend({
id: 1, // this.id
text: "", // this.text
}, attr));
};
var m = new Model({
text: "foo"
});
console.log(m);
// => { id: 1, text: 'foo' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment