分解对象

var obj = {
张三: [20, 50, 60],
李四: [88, 21, 33],
王五: [99, 23, 41]
};

  function splitObj(obj) {
    var A = [],
        B = [],
        C = [];
      let name = Object.keys(obj)
      var arr = Object.values(obj)
      for(let i = 0 ; i < arr.length; i ++) {
          A.push(arr[i][0]);
          B.push(arr[i][1]);
          C.push(arr[i][2]);
      }
      console.log(name)
      console.log(A)
      console.log(B)
      console.log(C)
  }

posted @ 2019-03-06 17:43  不得湖,涯也  阅读(129)  评论(0编辑  收藏  举报