I have a weird situation.
I take some values from a form and save it in an object.
I print out the values and it prints fine to the console log. But when I try to access it or print again in next line. It returns empty.
Here is the code.
var family = {};
var counter = [];
counter = document.querySelectorAll(".familyMemberBox input[name='member[]']");
for(x=0;x<counter.length;x++){
console.log('for loop');
family[x] = {};
member_number = counter[x].value;
member_type = get_member_type(member_number);
gender = get_gender(member_number);
age = get_age(member_number);
family[x]['type'] = member_type;
family[x]['Gender'] = gender;
family[x]['Age'] = age;
}
for(x=0;x<counter.length;x++){
console.log(family[x]);
}
console.log('family: '+family[0]);
here is the console output

console.log(family[x]);is logging the object.console.log('family: '+family[0]);is logging the string representation of the object, which is (unless you override it) "[object Object]"console.log('family: '); console.log(family[0]);console.log("family", family[0])insteadconsole.log('family: ', family[0]);instead ofconsole.log('family: '+family[0]);