Suppose I have the next javascript object:
var errors = {
error_1: \"Error 1 description\",
error_2: \"Error 2 description\",
error_3: \"\",
Here is a another good answer I found and wanted to share (after modification to fit my needs):
if ("property_name" in object_name && object_name.property_name !== undefined){
// code..
}
So if I wanted to apply this on my example, it will look like:
if ("error_1" in errors && errors.error_1 !== undefined){
// code..
}