I’ve posted this in General because it’s technically not a help question on a specific exercise or project. But if it’s in the wrong place my apologies.
Okay so let me preface this by saying I’ve just gotten to the constructor function section and I was going to put an example or two in my notes when something occurred to me. I had two options, I could make an array to store my reusable objects, for example:
var players = [
{
username : "Grabthar",
class: "Fighter",
level: 15
},
{
username : "Backstabz",
class: "Rogue",
level: 31
},
{
username : "Omin Dran",
class: "Cleric",
level: 99
}
]
Or I could make an object of objects:
var players = {
{
username : "Grabthar",
class: "Fighter",
level: 15
},
{
username : "Backstabz",
class: "Rogue",
level: 31
},
{
username : "Omin Dran",
class: "Cleric",
level: 99
}
}
Which got me thinking, in terms of creating, storing, and retrieving data like this, which way is better? I have to assume there’s some preference depending on what and how exactly you’re working with something. But do you guys have preferences? Does it matter?
For the sake of a more concrete example, let’s say I’ve got a game website where users can login and view their stats,equipment, maybe see the current top players, etc.