I'm currently trying to find if an object property "itemBag" is set in an object.
The issue I am having is that I am getting 2 different arrays from the api and the property "itemBag" is not included within the object so I get an "undefined" error.
The 2 different arrays that I get:
Array 1:
[
[
{
"orderNumber": 1,
"itemBag": [
{
"size": 10000,
"name": "hello.pdf",
}
]
}
]
]
Array 2:
[
[
{
"orderNumber": 1
}
]
]
The function that I am using to try to determine if "itemBag" is empty or not:
$scope.reproductions is the array mentioned above
$scope.checkFirstDesignContainerIsEmpty = function() {
var containerIsEmpty;
if($scope.reproductions[0][0].includes(itemBag)) {
containerIsEmpty = true;
}
return containerIsEmpty;
};
I keep getting an error that itemBag is undefined.
(parent.childArray || []).length === 0is a simple way to test if an array