Reputation: 1285
Why is the objects property undefined, when logging the whole object, that is not the case.
this the log:
console.log(JSON.stringify(obj));
[{"id":"base_data","title":"Base Data","widgetId":"base_data"}]
console.log(obj.title);
undefined
why???
Upvotes: 1
Views: 36
Reputation: 943097
Your object ({}
) is inside an array ([]
), and you are trying to access the title
property of the array, not the object.
console.log(obj[0].title);
Upvotes: 6