Let's say I'm implementing a.b.c.d
on separate file.
So, I need to check a,b,c is defined and fallback into catch clause when those property is not defined.
Currently, I'm using this code. But it's too long, dirty and hard to maintain.
try{
if(!("a" in window)) {
throw new Error();
}
if(!("b" in a)) {
throw new Error();
}
if(!("c" in a.b)) {
throw new Error();
}
} catch(e){ }
What is the best practice?