torso-bundle.js
function getNestedProperty(rootObject, propertyString) {
    propertyString = propertyString.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
    propertyString = propertyString.replace(/^\./, '');           // strip a leading dot
    var propertyStringParts = propertyString.split(PROPERTY_SEPARATOR);
    return _.reduce(propertyStringParts, function(currentBaseObject, currentPropertyName) {
      return _.isUndefined(currentBaseObject) ? undefined : currentBaseObject[currentPropertyName];
    }, rootObject);
  }
function getNestedProperty(rootObject, propertyString) {
    propertyString = propertyString.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
    propertyString = propertyString.replace(/^\./, '');           // strip a leading dot
    var propertyStringParts = propertyString.split(PROPERTY_SEPARATOR);
    return _.reduce(propertyStringParts, function(currentBaseObject, currentPropertyName) {
      return _.isUndefined(currentBaseObject) ? undefined : currentBaseObject[currentPropertyName];
    }, rootObject);
  }
function getNestedProperty ( rootObject , propertyString ) { propertyString = propertyString . replace ( / \[(\w+)\] / g , '.$1' ) ; // convert indexes to properties propertyString = propertyString . replace ( / ^\. / , '' ) ; // strip a leading dot var propertyStringParts = propertyString . split ( PROPERTY_SEPARATOR ) ; return _ . reduce ( propertyStringParts , function ( currentBaseObject , currentPropertyName ) { return _ . isUndefined ( currentBaseObject ) ? undefined : currentBaseObject [ currentPropertyName ] ; } , rootObject ) ; }
Gets a nested property from an object, returning undefined if it doesn't exist on any level.
@param rootObject {Object} object containing the property to get.
@param propertyString {String} string identifying the nested object to retrieve.
@return {*} either undefined or the property referenced from the rootObject.
Gets a nested property from an object returning undefined if it doesn t exist on any level .