title: dealing with loops in javascript, only last item gets affected?
body: <p>Im working with the gm npm module that deals with image manipulation. and i have this code.</p>
  
  <pre><code>for(i=0;i &lt; 4;i++){
      gm("www/img/" + image[i]).crop(550, 406, 0, 0).write(function(err) {
           console.log(this.outname + " created  ::  " + arguments[3]); //success
      });
  }
  </code></pre>
  
  <p>this loop is meant to loop through the images array and crop each photo, but it only crops the last one. i think its something to do function invocation and callbacks, but not advanced yet for that level.</p>