I've tried the suggestions from the top answer of the following topic but I'm not finding much luck:
However, if you search for a domain which does not exist this key is not returned in the object (fair enough).
All I want to do right now is assign the value of WhoisRecord.administrativeContact.name to a variable - I am happy for this variable to be blank or undefined if this key does not exist within the object, however the problem is that when I try and assign WhoisRecord.administrativeContact.name to a variable or check for its existence I get the good old "cannot read property of undefined" error if the API is not returning this information.
I understand 100% why this is happening, I just don't know how to get round it. The thread I linked at the top suggests using the "in" operator, which I've tried, but I can't get it to ever recognise that the object does contain this key, it's just always returning false.
Any advice/prodding in the right general direction appreciated.
Use logical AND like:
var name = WhoisRecord && WhoisRecord.administrativeContact && WhoisRecord.administrativeContact.name;