What is the best to select a javascript object property at any depth? I'm looking for suggestions on how to select properties on the child level or deeper dynamically.  

For example, here is the method that I am currently using. The method parameters is the object and either a string or array for the property name. If a string is passed used, it will just will get the property.  The array is iterated through in order to select the property value.

getMappedDataProperty: function(obj, map) {
  var m, result, _i, _len;
  if (typeof map === 'string') {
    return obj[map];
  }
  result = obj;
  for (_i = 0, _len = map.length; _i &lt; _len; _i++) {
    m = map[_i];
    result = result[m];
  }
  return result;
}


Even though this works, I keep thinking to myself that there has to be a better way of accomplishing this.  Suggestions?
From a once over:


getMappedDataProperty is a clumsy name, how about getProperty.
receiving a string is functionally the same as an array with 1 entry, so you could 
map = (typeof map === 'string') ? [map] : map;
There is no need for the underscores for i and len, also, I would rather see length than len
the use of the temporary variable m is overkill, you could go straight for result = result[map[i]];


I would counter propose:

getProperty: function( o, map ) 
{
  map = (typeof map === 'string') ? [map] : map.slice();
  var result = o;
  while ( map.length ) {
    result = result[ map.shift() ];
  }
  return result;
}


I would love to know the context in which you use this, since I cannot see a good use case for it.