I have the following code from a javascript book and the callback seems to be passed an expression as an argument. Is that the case or am I seeing this wrong? I didnt know, even though it works, that that was possible.
function multiplybytwo(a,b,c,callback) {
var i, ar =[];
for(i=0;i<3;i++)
{
ar[i] = callback(arguments[i]*2);
}
return ar;
}
function addone(a) {
return a+1;
}
myarr =multiplybytwo(1,2,3,addone);
is equivalent to
Same as
callback(1+2);tocallback(3);