title: Javascript callback function with parameter?
body: <p>I have this simple code : </p>
  
  <pre><code>console.log('calling doWork func...')
  doWork('a', 'b', myCb);
  
  function doWork(param1, param2, callback)
  {
          console.log('in func')
          callback();
  }
  
  
  function myCb(a)
  {
          console.log('in callback... for value ' + a)
  }
  </code></pre>
  
  <p>I'm running the  function with a callback function  -</p>
  
  <p>The output I get is : </p>
  
  <pre><code>"calling doWork func..."
  "in func"
  "in callback... for value undefined"    // notice the undefined
  </code></pre>
  
  <p>All ok.</p>
  
  <p>Now, I want the callback to be called with a <em>specified param</em>   - something like ( which is incorrect since the <code>()</code> is executing the func) : </p>
  
  <pre><code>doWork('a', 'b', myCb('xxxx'));
  </code></pre>
  
  <p>I want the output to be : </p>
  
  <pre><code>in callback... for value  xxxx
  </code></pre>
  
  <p>How do I send a parameter with the myCb call  in     <code>doWork('a', 'b', myCb);</code>? <em>( 'when you run the callback function , please run it according to value xxxx')</em></p>
  
  <p>any help ?</p>
  
  <p>p.s. I want to avoid any <em>global flags solution</em></p>
  
  <p>thanks.</p>