I have these nested objects. How can I check if the group_id are all the same?
console.log(getData);
{…}
"$": function g()
0: {…}
DT_RowId: "row_1"
groups: Object { group_id: 2, … }
1: {…}
DT_RowId: "row_2"
groups: Object { group_id: 2, … }
2: {…}
DT_RowId: "row_3"
groups: Object { group_id: 2, … }
3: {…}
DT_RowId: "row_4"
groups: Object { group_id: 2, … }
A .each() provides me:
$.each( getData, function ( id, val ) {
console.log(val.groups.group_id);
});
2
2
2
2
getDatais an array, you can useArray.every()to return true/false if every item in an array meets a given condition.getData? Seems like it is a jQuery object?? Hard to answer without knowing what it is.