title: How to group array with multiple objects in javascript
body: <p>I have an array</p>
  <pre><code>{
  &quot;id&quot;: 5308,
  &quot;empId&quot;: 202,
  &quot;loc&quot;: 1,
  &quot;salMonth&quot;: &quot;1&quot;,
  &quot;salYear&quot;: &quot;2020&quot;,
  &quot;salDate&quot;: &quot;2020-01&quot;,
  &quot;netSal&quot;: 50000
  },
  {
  &quot;id&quot;: 5309,
  &quot;empId&quot;: 173,
  &quot;loc&quot;: 1,
  &quot;salMonth&quot;: &quot;1&quot;,
  &quot;salYear&quot;: &quot;2020&quot;,
  &quot;salDate&quot;: &quot;2020-01&quot;,
  &quot;netSal&quot;: 30000
  },
  {
  &quot;id&quot;: 5310,
  &quot;empId&quot;: 212,
  &quot;loc&quot;: 1,
  &quot;salMonth&quot;: &quot;1&quot;,
  &quot;salYear&quot;: &quot;2020&quot;,
  &quot;salDate&quot;: &quot;2020-01&quot;,
  &quot;netSal&quot;: 21100
  },
  {
  &quot;id&quot;: 5311,
  &quot;empId&quot;: 163,
  &quot;loc&quot;: 1,
  &quot;salMonth&quot;: &quot;1&quot;,
  &quot;salYear&quot;: &quot;2020&quot;,
  &quot;salDate&quot;: &quot;2020-01&quot;,
  &quot;netSal&quot;: 43000
  },
  {
  &quot;id&quot;: 5312,
  &quot;empId&quot;: 116,
  &quot;loc&quot;: 1,
  &quot;salMonth&quot;: &quot;1&quot;,
  &quot;salYear&quot;: &quot;2020&quot;,
  &quot;salDate&quot;: &quot;2020-01&quot;,
  &quot;netSal&quot;: 52000
  },
  {
  &quot;id&quot;: 5313,
  &quot;empId&quot;: 223,
  &quot;loc&quot;: 1,
  &quot;salMonth&quot;: &quot;1&quot;,
  &quot;salYear&quot;: &quot;2020&quot;,
  &quot;salDate&quot;: &quot;2020-01&quot;,
  &quot;netSal&quot;: 21100
  },
  {
  &quot;id&quot;: 5314,
  &quot;empId&quot;: 231,
  &quot;loc&quot;: 1,
  &quot;salMonth&quot;: &quot;1&quot;,
  &quot;salYear&quot;: &quot;2020&quot;,
  &quot;salDate&quot;: &quot;2020-01&quot;,
  &quot;netSal&quot;: 42217
  }
  
  </code></pre>
  <p>I have to group this array by two colums, that is empId, salDate.</p>
  <p>And the expected result should like:</p>
  <pre><code>{
    &quot;202&quot;: {
      &quot;2020-01&quot;: {
        &quot;salId&quot;: xx,
        &quot;salary&quot;: xxx
      },
      &quot;2020-02&quot;: {
        &quot;salId&quot;: xxx,
        &quot;salary&quot;: xxxx
      },
      &quot;2020-03&quot;: {
        &quot;salId&quot;: xxx,
        &quot;salary&quot;: xxxx
      }
    },
    &quot;203&quot;: {
      &quot;2020-01&quot;: {
        &quot;salId&quot;: xx,
        &quot;salary&quot;: xxx
      },
      &quot;2020-02&quot;: {
        &quot;salId&quot;: xxx,
        &quot;salary&quot;: xxxx
      },
      &quot;2020-03&quot;: {
        &quot;salId&quot;: xxx,
        &quot;salary&quot;: xxxx
      }
    },
  
  }
  </code></pre>
  <p>Thanks Advance ............................................................................................................................................................................................................................................................................</p>