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