3 ms·
Good advice except for the last example which is brittle and unnecessary. If handleError() is ever changed this method could start returning values unexpectedly
by ebbv 9y ago
Good advice except for the last example which is brittle and unnecessary. If handleError() is ever changed this method could start returning values unexpectedly. Totally unnecessary and not a worthwhile "optimization" to save lines of code.
- timoxley 9y agoThe `err, results` params form the signature of a continuation-passing style "errback": function(err, results) { if (err) // … } It is assumed that this function will be executed asynchronously, and thus it's not possible for anything to consume the return value anyway. If you want to control the return value, simply return on a new line or use the void operator: return void handleError(err)