Javascript: How To Access An Array Object?
Solution 1:
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;
Solution 2:
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].picturepathSimilarly, 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.
Solution 3:
If you want to do operations on an object that is printed to the chrome console, right click on the object and do Store as global variable. Then you can access it using the name temp1 or whatever is printed out in the console.

Post a Comment for "Javascript: How To Access An Array Object?"