ES6 void Keyword
It specifies an expression to evaluate without returning any value. The void operator is often used for obtaining the undefined primitive value.
x = undefined y = 50 z = 70
Immediately Invoked function expressions (IIFE) and void keyword
Using an IIFE, the void can be used for forcing the function keyword to be treated as an expression rather than a declaration.
The void operator can be used to return the undefined value.
Let us understand the illustration for the same.
When you click on the second link, then it will display an alert dialog box.
After the successful execution of the above code, you will get the following output:
When you click on the first link, you will get nothing. But, on clicking the second link, you will get the following screen: