while inspecting in browser, I am getting this type of array and I am unable to access 0th index of array.
function xyz()
{
var obj={
name: "abc",
age: "20"
var VArr=[];
VArr.push(obj);
}
[] 0:Array(1) 0:{name:"abc",age:"20"}
while inspecting in browser, I am getting this type of array and I am unable to access 0th index of array.
function xyz()
{
var obj={
name: "abc",
age: "20"
var VArr=[];
VArr.push(obj);
}
[] 0:Array(1) 0:{name:"abc",age:"20"}
First acess to the array by VArr[0]
inside this u have your objecet to access your object property use dot notation like this
console.log(VArr[0].name)
Full code
function xyz(){
var obj={
name: "abc",
age: "20"
}
var VArr=[];
VArr.push(obj);
console.log(VArr[0].name)
}
xyz()