On Jun 9, 9:30 am, Anton Kovalyov <[email protected]> wrote:
> I used the void operator today in a case when I needed to call a function,
> discard its return value and then return undefined. I did that mostly to be
> able to omit curly braces in the one-line if statement (i personally think
> they are ugly, especially when used in a very small constructions; python
> thing):
>
> function sample(callback) {
> // Do something
>
> if (cond)
> return void callback();
>
> // Do something else
>
> }
It seems to me that that is precisely what the void operator is for.
But I would think the following is easier to understand and therefore
more maintainable:
function sample(callback) {
if (cond) {
callback();
} else {
// do other stuff
// return some value?
}
// implied return undefined;
}
or
function sample(callback) {
if (!cond) {
// do other stuff
// return some value?
}
callback();
}
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]