Last active
August 29, 2015 14:14
-
-
Save appkr/f53bfcc092f345a6cb7b to your computer and use it in GitHub Desktop.
JavaScript Data & Accessor// source http://jsbin.com/muraqe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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