Skip to content

Instantly share code, notes, and snippets.

@appkr
Last active August 29, 2015 14:14
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 appkr/f53bfcc092f345a6cb7b to your computer and use it in GitHub Desktop.
Save appkr/f53bfcc092f345a6cb7b to your computer and use it in GitHub Desktop.
JavaScript Data & Accessor// source http://jsbin.com/muraqe
var createPerson = function(firstName, lastName) {
var person = {};
Object.defineProperties(person, {
firstName : {
value : firstName,
enumerable : true
},
lastName : {
value : lastName,
enumerable : true
},
fullName : {
get : function() {
return this.firstName + " " + lastName;
},
enumerable : true
}
});
return person;
};
var person = createPerson("John", "Doe");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment