183
rated 0 times
[
185]
[
2]
/ answers: 1 / hits: 5994
/ 10 Years ago, wed, july 2, 2014, 12:00:00
I'd like to iterate trough a javascript array (nested objects: based on collection+Json) and collect data from its objects. But if the data of an object isn't available, skip it and go to the next object, resp. continue the iteration. Currently, this error appears if the data isn't available in the according object: Uncaught TypeError: Cannot read property 'hk5' of undefined
How can I check first, if the data (hereafter hk5) is available?
Iterating through all data-objects
for (var i = 0; i < data.collection.items.length; i++) {
var data = data.collection.items[i].data[2].value.packet_data_field.application_data_params.hk5;
console.log(belaMode);
}
Thanks!
More From » arrays