Skip to content

Instantly share code, notes, and snippets.

@azder
Last active December 17, 2015 05:39
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 azder/5559489 to your computer and use it in GitHub Desktop.
Save azder/5559489 to your computer and use it in GitHub Desktop.
function Model(){
var data = {};
// accessor
this.data = function(name, value){
// null makes it a deleter
if(null === value) {
delete data[name];
return this;
}
// undefined makes it a getter
if('undefined' === typeof value){
return value;
}
// primitive or object make it a setter
data[name] = value;
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment