In the code here the first example just does callbacks, the second example does "return callback".
Under what circumstances should I do "return callback" instead of just "callback"?
this.listRegions((err, regions) => {
if (err) {
callback(err)
} else {
callback(null, regions)
}
})
OR
this.listRegions((err, regions) => {
if (err) {
return(callback(err))
} else {
return(callback(null, regions))
}
})
returnin order to get out of the function, though, as a kind of shorthand forcallback(null, regions); return. For instance, in the second sample code you show, this would allow you to eliminate theelsepart. BTW, the parens are not required around the return value and many popular style guides call for you not to use them.