title: get latest date for each day in an array of object?
body: <p>i have array of object which are sorted based on date/time, I have to form an array of object with latest data from each date?. I'm getting the solution with for loop but I need to use es6 and above, please help me with a better and advanced solution.</p>
  <pre><code>var array = [
    {
      &quot;id&quot;: 1,
      &quot;date&quot;: &quot;2016-01-15T16:18:44.258843Z&quot;,
      &quot;status&quot;: &quot;NEW&quot;,
      &quot;request&quot;: 4
    },
   {
      &quot;id&quot;: 2,
      &quot;date&quot;: &quot;2016-01-15T18:18:44.258843Z&quot;,
      &quot;status&quot;: &quot;NEW&quot;,
      &quot;request&quot;: 4
    },
   {
      &quot;id&quot;: 3,
      &quot;date&quot;: &quot;2016-01-15T20:18:44.258843Z&quot;,
      &quot;status&quot;: &quot;NEW&quot;,
      &quot;request&quot;: 4
    },
    {
      &quot;id&quot;: 4,
      &quot;date&quot;: &quot;2016-01-19T16:18:44.258843Z&quot;,
      &quot;status&quot;: &quot;STD&quot;,
      &quot;request&quot;: 4
    },
    {
      &quot;id&quot;: 6,
      &quot;date&quot;: &quot;2016-01-23T17:18:44.258843Z&quot;,
      &quot;status&quot;: &quot;FOR&quot;,
      &quot;request&quot;: 4
    },
  {
      &quot;id&quot;: 5,
      &quot;date&quot;: &quot;2016-01-23T16:18:44.258843Z&quot;,
      &quot;status&quot;: &quot;FOR&quot;,
      &quot;request&quot;: 4
    }]
  const list = filter(array, el =&gt; (el.date));
     latestDate = list[0]?.date.slice(0, 10);
     latestResponse.push(res[0]);
   for (let i = array.length - 1; i &gt; 0; i--) {
        if (this.latestDate !== array[i].date.slice(0, 10)) {
        latestDate = (array[i].date).slice(0, 10);
          latestResponse.push(res[i]);
        }
      }
  </code></pre>
  <p>expected Output</p>
  <pre><code>var array = [
       {
          &quot;id&quot;: 3,
          &quot;date&quot;: &quot;2016-01-15T20:18:44.258843Z&quot;,
          &quot;status&quot;: &quot;NEW&quot;,
          &quot;request&quot;: 4
        },
        {
          &quot;id&quot;: 4,
          &quot;date&quot;: &quot;2016-01-19T16:18:44.258843Z&quot;,
          &quot;status&quot;: &quot;STD&quot;,
          &quot;request&quot;: 4
        },
      {
          &quot;id&quot;: 5,
          &quot;date&quot;: &quot;2016-01-23T17:18:44.258843Z&quot;,
          &quot;status&quot;: &quot;FOR&quot;,
          &quot;request&quot;: 4
        }]
  </code></pre>