title: Can't iterate into javascript array of objects
body: <p>I come to you because i have some issues using javascript arrays.</p>
  
  <p>I'm trying to iterates through a javascript array filled with some objects.
  I have totally 4 objects.</p>
  
  <p>this is my code :</p>
  
  <pre><code>// sort trainings_tab descending order
  trainings_tab = trainings_tab.sort(function(a, b) {
      if (a.date_from &lt; b.date_from)
          return 1;
      else if(a.date_from &gt; b.date_from)
          return -1;
      return 0;
  });
  
  console.log(trainings_tab);
  for(var h = 0; h &lt; trainings_tab.length; h++) {
  
      // var training = new_array[h];
      console.log(trainings_tab[h]);
  }
  </code></pre>
  
  <p>and what i've got from console.log(trainings_tab); =></p>
  
  <pre><code>[] (i have a little blue i here that say : object value at left was snapshotted when logged value below was evaluated just now)
   0: Object
      _geoloc: Object
      _highlightResult: Object
      _rankingInfo: Object
      address: "Hospital da plastica, Rio de Janeiro, Brazil"
      address_id: 16623
      date_from: "1479769200"
      date_to: "1480028400"
      device: "USD"
      doctor_full_name: "John Doe"
      doctor_id: "85"
      doctor_image: "/images/avatar_85.jpg"
      doctor_url: "/profile/85"
      guest: "2"
      labo_id: "8So7KJPmv4qyL2uHD"
      langues: "English"
      objectID: "689"
      objectives: Array[2]
      price: "1000"
      procedures: Array[1]
      products: Array[1]
      seat_left: "2"
      seat_taken: 0
      speciality: "PLASTIC SURGERY, BODY CONTOURING"
      training_full: ""
      training_name: "Lipofacillomaxial"
      url: "/training/detail/689"
      __proto__: Object
   1: Object
   2: Object
   3: Object
   length: 4
   __proto__: Array[0]
  </code></pre>
  
  <p>Each objects looks like the first one, with other datas ofc.
  But the problem is that my for loop doesn't iterate other the array and i can't see the console.log(trainings_tab[h]);</p>
  
  <p>Someone has an idea and can help me plz ? Thanks.</p>
  
  <p><strong>EDIT : HOW DO I POPULATE MY TAB ?</strong> </p>
  
  <p>i assign a var at empty tab :</p>
  
  <pre><code>var trainings_tab = [];
  </code></pre>
  
  <p>I use ALGOLIA (<a href="https://www.algolia.com/" rel="nofollow">https://www.algolia.com/</a>) to search into an index called 'training' and that get all my records. When the search is done i have a callback and i'm doing this :</p>
  
  <pre><code>function searchDone(err, content) {
          if (err) {
              console.error(err);
              return;
          }
          //console.log(content.hits);
          for(var i = 0; i &lt; content.hits.length; i++) {
              var training = content.hits[i];
  
              // check that's a training
              if (training &amp;&amp; training.date_from != null) {
                  // calculate  seats taken
                  var seats_taken = training.guest - training.seat_left;
  
                  var training_full = '';
                  // training is full ?
                  if (training.seat_left == 0) training_full = 'training-full';
  
                  training.seat_taken = seats_taken;
                  training.training_full = training_full;
  
                  if (training.hidden == false || training.hidden == null)
                      Session.set("countTrainings", Session.get("countTrainings")+1);
  
                  trainings_tab.push(training);
              }
          }
  
      }
  </code></pre>
  
  <p>It seems that my problem is when i populate the trainings_tab, because if i console.log before the sort, i have the same display than quoted before...</p>