function accessObjectByString(object, string) {
  try {
    let newObject = JSON.parse(JSON.stringify(object))
    if (string && string.length) {
      string = string.replace(/\[(\w+)\]/g, '.$1') // convert indices to properties e.g [0] => .0
      string = string.replace(/^\./, '') // strip leading dot

      let splitString = getArrayForStringPath(string)
      for (let i = 0; i < splitString.length; i++) {
        let key = splitString[i]
        newObject = newObject[key]
      }
    }

    return newObject
  } catch (e) {}
}
Access object by string.

@param {Object} object
@param {String} string
@param {Object}