|
November 20, 1999 The void Operator Tips: November 1999
Yehuda Shiran, Ph.D.
|
|
The void operator specifies an expression to be evaluated without returning a value. Its syntax may be similar to one of the following:
or:
Let's examine the following example:
The preceding script segment displays two alert boxes. The first box displays the string
This script also generates two alerts, but the second one reads
A more important use of this operator is in hypertext links, where it is used to evaluate a JavaScript expression in line. The expression is evaluated but it is not loaded back into the current document. The following link does nothing because the expression
The following link generates an alert box when the link is clicked:
The parentheses are optional. We chose to use them in order to make the script more readable.
People who read this tip also read these tips: Look for similar tips by subject: |