Callbacks: when to return value, and when to modify parameter?
- by MarkN
When writing a callback, when is best to have the callback return a value, and when is it best to have the callback modify a parameter? Is there a difference?
For example, if we wanted to grab a list of dependencies, when would you do this:
function GetDependencies(){
return [{"Dep1" : 1.1},
{"Dept2": 1.2},
{"Dep3" : 1.3}];
}
And when would you do this?
function RegisterDependencies(register){
register.add("Dep1", 1.1);
register.add("Dep2", 1.2);
register.add("Dep3", 1.3);
}