Skip to content Skip to sidebar Skip to footer

Not Able To Get Values From Js Object

Can you please take a look at this demo and let me know why I am not able to extract values from the object?

Solution 1:

The manyNames object is at the 8th index of the array, so therefore you need this:

console.log(obj.onDays[8].manyNames[1]);

For jack:

console.log(obj.onDays[7].name);

Or age:

onsole.log(obj.onDays[7].age);

Solution 2:

You should understand the basic difference between array and object.

Whenever you deal with an Array, access by index.

arr[index]; // obj["onDays"][7]["name"];

Whenever you deal with an Object, access by the property.

obj[property] or obj.property // obj["find"];

Post a Comment for "Not Able To Get Values From Js Object"