react 数组 const arr1= [
    {“id”:”1”,”key_name”:”a”,”key_value”:”aaa”},
    {“id”:”2”,”key_name”:”b”,”key_value”:”bbb”},
    {“id”:”3”,”key_name”:”c”,”key_value”:”ccc”},
    {“id”:”3”,”key_name”:”d”,”key_value”:”ddd”},

    ];
    要为转为 对象 obj ={“a”:”aaa”,
    “b”:”bbb”,
    “c”:”ccc”,
    “d”:”ddd”}

    请问哪位高手知道要怎么转换?

    var obj = {}
    for(var i=0;i obj[arr1[i].key_name] = arr1[i].key_value
    }
    console.log(obj)

    let arr = arr1.map(item => {
    let obj = {};
    obj[item.key_name] = item.key_value;
    return obj;
    })