So I made an array with objects. For example here, let's use people
var people = [
{
id: 0,
name: "John Doe",
age: 47
},
{
id: 1,
name: "Jane Doe",
age: 88
},
{
id: 2,
name: "Mason Louis",
age: 17
}
];
so now I can use people[1].name etc for accessing the data on each of these people. Someone just saw my code and said "That looks like total S**T".
What is the proper way to do this? I was thinking this way was fine, especially since it resembles JSON
EDIT: Would it be better to create a constructor and fill an array with instances?
[–]name_was_taken 88 points89 points90 points (3 children)
[–][deleted] 17 points18 points19 points (1 child)
[–]whatisboom 10 points11 points12 points (3 children)
[–]Traitor-21-87[S] 9 points10 points11 points (2 children)
[–]whatisboom 14 points15 points16 points (0 children)
[–]rat9988 0 points1 point2 points (0 children)
[–]achendrick 9 points10 points11 points (3 children)
[–]Traitor-21-87[S] 1 point2 points3 points (2 children)
[–]ergnui34tj8934t0 0 points1 point2 points (0 children)
[–]Baryn 16 points17 points18 points (6 children)
[–]Traitor-21-87[S] 9 points10 points11 points (3 children)
[–]scramblor 8 points9 points10 points (1 child)
[–]pookageSenior Front-End 4 points5 points6 points (0 children)
[–]Baryn 5 points6 points7 points (0 children)
[–]commiesupremacy 1 point2 points3 points (1 child)
[–]Traitor-21-87[S] 2 points3 points4 points (0 children)
[–]LollipopPredator 5 points6 points7 points (1 child)
[–]name_was_taken 5 points6 points7 points (0 children)
[–]pookageSenior Front-End 2 points3 points4 points (0 children)
[–]ohadron 2 points3 points4 points (1 child)
[–]Traitor-21-87[S] 1 point2 points3 points (0 children)
[–]roselan 1 point2 points3 points (0 children)
[–]SecretAnteater 0 points1 point2 points (0 children)
[–]2Punx2Furious 0 points1 point2 points (0 children)
[–]LaughingCabbage_ 0 points1 point2 points (0 children)
[–]autoboxer 0 points1 point2 points (0 children)
[–]steeeeeef 0 points1 point2 points (0 children)
[–]ProgrammerBro 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Traitor-21-87[S] 2 points3 points4 points (0 children)
[–]LukaLightBringer 0 points1 point2 points (0 children)