I want to convert an array to an object. How can I convert it?

Array

          let arr=[
                     {user:"123"},
                    {Cause:"22"},
                    {EnterFactoryTime:"33"},
                    {OutFactoryTime:"44"},
                    {VehicleGrade:"55"},
                    {IncomingInspection:"66"},
                    {Admission:"77"}
             ];
             console.log(arr);

clipboard.png


clipboard.png

what method can be used

May.30,2021

Object.assign(...arr)

brief analysis:

object merge ( Object.assign ) plus extension operator (. )


you can try this method:

var result= arr.reduce((item1,item2)=>Object.assign(item1,item2));
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e473e8-44c0d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e473e8-44c0d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?