侃侃尔雅
let obj = {
a: {
b: {
c: 'hey',
}
}}let objProps = ["a", "b", "c"];function findValue(obj, objProps, index = 0) {
if (index > objProps.length-1) return obj;return findValue(obj[objProps[index]],objProps, index+1)}findValue(obj, objProps)let obj = {
a: {
b: {
c: 'hey',
}
}}let objProps = ["a", "b", "c"];function assignValue(obj, objProps, newValue, index = 0) {
console.log(obj)
if (index >= objProps.length-1 && obj[objProps[index]]) {
return obj[objProps[index]] = newValue;
} else {return assignValue(obj[objProps[index]],objProps, newValue, index+1)
}}assignValue(obj, objProps, "asdsa")