As I delved into learning about Objects in Javascript, I came across an example involving users that left me with a question.
let users = [
{
"id": "1",
"name": "John",
"age": 20,
"address": "123 Main Street"
},
{
"id": "2",
"name": "Emma",
"age": 23,
"address": "12 Main Street"
}
]
console.log(users[0].id);
Upon reviewing this code snippet, I found it slightly perplexing that by using users[0], I was accessing data related to John, whose ID is '1'. This raised doubts in my mind regarding the coding style employed here. Is this approach correct, or have I made an error? Does it adhere to established conventions?
I aimed to assign unique IDs to users, but coupling index numbers with ID values appears somewhat unconventional to me.