let arr = [ { name: 'animal', id: 1, parent: null }, { name: 'dog', id: 2, parent: 1 }, { name: 'cat', id: 3, parent: 1 } ] let obj = { id: 1, name: 'animal', children: [ { id: 2, name: 'dog', children: null }, { id: 3, name: 'cat', children: null } ] } let obj2 = arr.reduce( (result, item) => { } , {})