I know this post is quite old but its strange I can't see very popular "Lodash" solution here which allows to get object nested properties safely.
Example:
var object = {
a: [
{
b: {
c: 3
}
}
]
};
_.get(object, 'a[0].b.c'); // → 3
For your example:
var person = {
name: 'Joe',
contact: {
phone: '555'
}
}
var personPhoneProp = 'contact.phone';
_.get(person, personPhoneProp); // -> '555'
Documentation: https://lodash.com/docs#get