You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

19 lines
326 B

'use strict';
/**
* Get value of a nested property
*
* @param mainObject
* @param key
* @returns {*}
*/
module.exports = function nestedValue(mainObject, key) {
try {
return key.split('.').reduce(function (obj, property) {
return obj[property];
}, mainObject);
} catch (err) {
return null;
}
};