Created
June 21, 2013 17:15
-
-
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 }
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 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(); | |
} |
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 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