I'm writing an app in Javascript, and while I'm comfortable with the language, I was wondering about unused parameters.
Say I have a function as follows:
function test(data, complete){
if (data){
return complete(null, 'yes');
}
else{
return complete('error', null);
}
}
I call that function with a callback, but am only interested in checking for an error - if the data exists, I can move forward with my program. Is it okay if I just pass the error parameter into the function?
test(data, function(err){
if(err){
//Uh Oh
}
else{
//Keep going
}
});
Or is it best if I pass both the error and the result (even though the result variable remains unused)?
test(data, function(err, result){
if(err){
//Uh Oh
}
else{
//Keep going
}
});