title: async each variable scope in nodejs
body: <p>I am using async each to loop through and constructing an object called <code>coupon_bo</code>. Surprisingly inside <code>processbo</code> function, I am seeing a side effect where only the last copy of <code>coupon_bo</code> object is available to <code>processbo</code> function. </p>
  
  <p>My understanding is that since <code>coupon_bo</code> is local to each iteration, there should be a new object for iteration.</p>
  
  <p>Am I missing something?</p>
  
  <pre><code>function hitApplyLogic(coupon_names, coupons_list, req, callback) {
      async.each(coupon_names, function(coupon_name, callback) {
          var coupon_bo = new coupon_objects.CouponsBO();
          coupon_bo.incoming_request = req.body;
          coupon_bo.incoming_request['coupon_code'] = coupon_name.cn;
          coupon_bo.incoming_request['list_offers'] = true;
  
          setTimeout(function()
          {
              console.log("CONSOLE-BO: " + JSON.stringify(coupon_bo));
  
          }, 1000);
      });
  }
  </code></pre>