I am trying to check if key ("Gen") exists and if exists return the value itself if not return "Unknown".
my object looks like this.
study = {
"005":
{
"Gen" : ["F"],
"vr" : "cs"
}
}
study = {
"005":
{
"vr" : "cs"
}
}
in function i am trying to return the value of "Gen"
var gen = study["005"].Gen !== "undefined" || study["005"].Gen !== null ? study["005"].Gen[0] : "Unknown";
but here it throws me an error as in second case : where "Gen" doesn't exist but still it passes the if condition and looks for study["005"].Gen[0]
how to check if the "Gen" exists!! Any help appreciated.