/** * @params {array}:待转对象数组 * @returns {Object} * fromPairs([['fred', 30], ['barney', 40]]) * >{"fred":30,"barney":40} */ function fromPairs(array) { let result = {}; if(!array||!array.length){ return result; } for(const item of array){ result[item[0]] = item[1] } return result; } console.log(fromPairs([['fred', {aa:'aa'}], ['barney', 40]]))