SOURCE

let obj ={
    'thisA':'a',
    'thisB':{
        'thisBC':'bc',
        'thisBD':{
            'thisBDE':'bde',
        }
    }
}

function change(obj,str){
    let res = null;
    let arr = str.split('.');
    let last = arr[arr.length-1];
    let changeLast = last.replace(/(A-Z)/g,'_$1').toLowerCase();
    let newObj = {};
    arr.reduce((pre,cur)=>{
        res = pre[cur];
        newObj[changeLast] = res;
        return res
    },obj);
    obj[changeLast] = newObj[changeLast];
    return obj
}

console.log(change(obj,'thisB.thisBD'));
console 命令行工具 X clear

                    
>
console