Why would someone write:
function () {
if (err) {
return void console.log(err)
}
}
instead of:
function () {
if (err) {
console.log(err)
return
}
}
Has anyone used the void operator at all? I have seen it being used as in the example case above, but very very rarely.
Update
console.log might be a poor example as it returns void itself. Let me show another use I have seen in an express app:
function (req, res) {
...
// Some error occurred
if (err) {
return void res.send(foo)
// `send` returns a `Response` instance
}
}
In eslint's source code for example, it is being used quite a lot: