Do I have to check if an object has a specific property when e.g. using a for-loop to access it like:
for(var i = 0; i<array.length< i++) {
console.log(array1[i].propertyName)
}
If the objects stored in the array differ for some having the specific property and some don't. Should I check it first with obj.hasOwnProperty(prop) or does it return undefined anyway without any conflicts?
You can check if the property exists with a simple if statement. As VLAZ pointed out, a missing property will return undefined which in JavaScript is equivalent to false (ey). So you could do:
for(var i = 0; i<array.length< i++) {
//Will return false if the property doesn't exist
if(array1[i].properyName != undefined) {
console.log(array1[i].propertyName)
}
}