i'm trying to access to an array object, but i just receive a "undefined" message on my console, i tried several ways of this forum, but no one helped me, please show me how to access it
4 Answers
It is no clear which array you want to access. In javascript it is simple to access array with Index like nameOfarray[Index].property_name.
var user=[
{'name':'abc',id:1,'subject':[{'math':90,'english':80}]},
{'name':'abc1',id:2,'subject':[{'math':90,'english':80}]},
{'name':'abc2',id:3,'subject':[{'math':90,'english':80}]}
];
val name=user[0].name; var math_mark=user[0].subject[0].math;
Comments
What you have here is basically an array of objects.
Let's say arrayobj represents your variable that contains this whole thing that you've done a console.log of, so to access, say, picturepath of the first object (which has index 0 in the array), you can write -
arrayobj[0].picturepath
Similarly, by changing the index (of the array), you can get to the next object and to access object elements, you have to use .elementindex
So in general -
array[arrayindex].objectindex should give you the required results.

var arrObjs = [{'administrator_id': 3}, {'administrator_id': 4}]; var firstAdministratorId = arrObjs[0].administrator_idthenorsubscribehandler or callback.