title: filter array of objects based on month and year
body: <p>I want to display the objects based on the current month and year  </p>
  
  <p>This filters the objects based on the month, I need to filter objects based on the year also.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var array = [{
      title: "a",
      date: "2018-03-29"
    }, {
      title: "b",
      date: "2018-04-13"
    }, {
      title: "c",
      date: "2018-04-12"
    }, {
      title: "leave",
      date: "2018-04-11"
    }, {
      title: "d",
      date: "2018-06-16"
    }],
    currentMonth = new Date().getMonth() + 1,
    events = array.filter(e =&gt; {
      var [_, month] = e.date.split('-'); // Or, var month = e.date.split('-')[1];
      return currentMonth === +month;
    });
  console.log(events);</code></pre>
  </div>
  </div>
  </p>