void operator evaluates the given
expression and then returns
This operator allows inserting expressions that produce side effects into places where an expression that evaluates to
undefined is desired.
void operator is often used merely to obtain the
undefined primitive value, usually using "
void(0)" (which is equivalent to "
void 0"). In these cases, the global variable
undefined can be used instead (assuming it has not been assigned to a non-default value).
When wrapping an entire script in an immediately-invoked function expression,
void can be used to force the
function keyword to be treated as an expression instead of a declaration.
When a browser follows a
void operator can be used to return
undefined. For example:
Note, however, that the