Void is an important keyword in JavaScript that can be used as a unary operator before its single operand, and may be of any type.
This operator specifies an expression that does not require a return value to be evaluated. Its syntax may be one of the following:
Or
void (func ())
Javascript:void (func ())
//-->
</script>
Example 1:
The most common use of this operation is the client-side Javascript:url, which evaluates the expression that calculates its boundary effect, without displaying the browser that evaluates the value of an expression.
Here, the expression alert (' Warning!!! ') evaluates the evaluation, but is not loaded back into the current document:
Example 2:
Another example of the link below does nothing, because the expression "0" has no effect in JavaScript. Here, the expression "0" is evaluated, but it is not loaded back into the current document:
Example 3:
Another use of void is to intentionally produce an indeterminate value, as follows: