title: Cannot read property 'xxxx' of undefined
body: <p>Hi i'm a student and i begin in dev. I try to make a histogram with chart.js. The x is the number of a week and the y a sum.  For this i make this code</p>
  
  <pre><code>function sumWeek(data) {
    var week = new Date(data[0].dateHisto).getWeek();
    var month = new Date(data[0].dateHisto).getMonth();
    var year = new Date(data[0].dateHisto).getFullYear();
    var table = [0, year, month, week];
    var sum = 0;
    for (var i = 0; i &lt; data.length; i++) {
      sum += parseInt(data[i].energy) / 1000;
    }
  
  table.splice(0, 1, sum);
  tableWeek.push(table);
  }
  for (k = 1; k &lt;= 52; k++) {
    var resultW = dataH.filter(function(data) {
      var date = new Date(data.dateHisto);
      return date.getWeek() == k;
    });
    sumWeek(resultW);
  }
  </code></pre>
  
  <p>My problem : when a week don't have data, the console write </p>
  
  <pre><code>index.php?page=history_currently:11606 Uncaught TypeError: Cannot read property 'dateHisto' of undefined
  at sumWeek (index.php?page=history_currently:11606)
  at createHistoWeek (index.php?page=history_currently:11640)
  at index.php?page=history_currently:11414
  </code></pre>
  
  <p>Edit 09/05: My bad, i did not explain well. At a moment, a week doesn't have data and return an aray empty like 
      <code>[]</code>
  When i have a data, i have 
      <code>{energy: "19530", dateHisto: "2019-01-28"}</code>
  When the data is empty the function doesn't work and return the uncaught typeError. And for the moment i don't find a solution ^^ Ty for the answer </p>