I know how to write a callback function with coffee-script,like this:
test1=require('./test1') test1.cube (result) -> console.log(result)
I want to know how to add a parameter into callback function? so that I can use it like this:
test1.cube(para,result)-> //use *para* to compute a *result* //here can do something with *result*
If I understand you correctly, what you want is this:
cube = (x, callback) -> callback(x * x * x) cube 3, (result) -> console.log 'the cube of 3 is ', result
This recipe can be found in it's original form on Stack Over Flow.