SOURCE

var arr = [
  {id: 5, name: 'asvsddf', value: 22, childrenIds:[9]},
  {id: 6, name: 'sdfbb', value: 111, childrenIds:[7, 10]},
  {id: 3, name: 'asdf', value: 999, childrenIds:[]},
  {id: 2, name: '12sad', value: 888, childrenIds:[4]},
  {id: 4, name: 'akldf', value: 33, childrenIds:[5, 6]},
  
  {id: 7, name: '---df', value: 011, childrenIds:[]},
  {id: 9, name: 'ad++f', value: 991, childrenIds:[]},
  {id: 10, name: 'a出差sdf', value: 909, childrenIds:[]},
];
function arrToMapWithParent(arr) {
  let obj = {};
  arr.forEach(item => {
    item.childrenId
    obj[item.id] = item;
  })
	return obj;
}
var mapObj = arrToMapWithParent(arr);
console.log(JSON.stringify(mapObj));
function listToTree(arr) {
  arr.forEach(item => {
      
    
  })
}
console 命令行工具 X clear

                    
>
console