2

I am having issues with reading some data where I'm getting undefined:

obj = {
    "people": [
        {
            "id": "123",
            "description": "some desc",
            "names": [
                {
                    "name": "Mark"
                }]
        }]

}

console.log(obj.people[0].names.name);

What I'm I doing wrong here?

1
  • console.log(obj.people[0].names[0].name); Commented Oct 13, 2016 at 10:03

2 Answers 2

2

names is an array, make it

console.log(obj.people[0].names[0].name);
Sign up to request clarification or add additional context in comments.

Comments

0

names is also an array.

Try this,

console.log(obj.people[0].names[0].name);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.