title: NodeJS Count how many objects in array?
body: <p>How would I count how many objects there are inside an array?</p>
  
  <p>The array looking like:</p>
  
  <pre><code>[ {id: 1}, {id: 2}, ...]
  </code></pre>
  
  <p>I assume I could use count() if it was PHP, but what about NodeJS/Javascript?</p>
  
  <p>Edit: </p>
  
  <p><img src="https://i.stack.imgur.com/G9TxO.png" alt="asd"></p>
  
  <pre><code>if (offer.items_to_receive.length &gt; 0) { 
      console.log("items: " + offer.items_to_receive.length);
      for(var i = 0; i &lt; offer.items_to_receive.length; i++) {
          usersInRound.push(offer.steamid_other);
      }
  }
  
  logData('Accepted trade offer from ' + offer.steamid_other + '. (tradeofferid: ' + offer.tradeofferid + ')\nWorth ' + offer.items_to_receive.length + ' tickets. ');
  </code></pre>
  
  <p>How come it can read the "worth X tickets", but not the other part?</p>