title: Javascript foreach with condition
body: <p>Here you can see my code : </p>
  
  <pre><code>this.tiles.forEach ( function($tile)
      {
              $tile.content.x = ( $tile.posY - $tile.posX ) * ($tile.map.tilesWidth/2) + ($tile.offsetX + $tile.map.offsetX);
              $tile.content.y = ( $tile.posY + $tile.posX ) * ($tile.map.tilesHeight/2) + ($tile.offsetY + $tile.map.offsetY);
  
              $tile.content.tile = $tile;
      });
  </code></pre>
  
  <p>So, for each tile in my array <code>tiles</code> i do some calculs.</p>
  
  <p>Each item in my array have an attribut <code>posX</code> and <code>posY</code>.</p>
  
  <p>My probleme here it's if i have a lots of tiles in my array, this foreach take a long time to execute.</p>
  
  <p>I need to add a condition and do this stuff for each tile where posX is between Xmin and Xmax, same thing for posY.</p>
  
  <p>How can i do that as simply as possible? To save the greatest possible resource.. thanks !</p>
  
  <p>Add a if condition in my array is not a good solution cause the foreach will still go through the whole array..</p>