code: function elegantlyGet(obj, props) {
    if (typeof props === 'string') {
      props = props.split('/')
    }
  
    if (props.length === 0) {
      return obj
    }
  
    var prop = props.shift()
  
    if (prop && obj.hasOwnProperty(prop)) {
      return elegantlyGet(obj[prop], props)
    }
  
    return undefined
  }
docs: http://www.zhihu.com/question/27100221/answer/35264735