Skip to content

Instantly share code, notes, and snippets.

@theoperatore
Created June 21, 2013 17:15
Show Gist options
  • Save theoperatore/5832758 to your computer and use it in GitHub Desktop.
Save theoperatore/5832758 to your computer and use it in GitHub Desktop.
Best Practice? Later on, I'll need to do a check on 'features' to see if a member exists: var alex = new Character(); if (alex.features['awesome']) { //do something } else if (alex.features['job']) { //not a member }
var Character = function() {
this.char_name = 'Alex';
this.char_level = 1;
this.char_race = 'Human';
this.features = {
'field of study' : 'Computer Science',
'awesome' : true;
};
this.health = new HpSpace();
}
var Character = function() {}
Character.prototype = {
char_name : 'Alex',
char_level : 1,
char_race : 'Human'
features : {
'field of study' : 'Computer Science',
'awesome' : true
},
health : new HpSpace() //function defined somewhere else
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment