这个问题在这里已经有了答案:Howtosetobjectproperty(ofobjectpropertyof..)givenitsstringnameinJavaScript?(16个答案)关闭6年前。我正在尝试为一个对象深度赋值。例如:consterrors={}if(errorOnSpecificField){//TypeError:Cannotreadproperty'subSubCategory'ofundefined(…)errors.subCategory.subSubCategory.fieldWithError='ErrorMessage'}现在,没有lodash,我