JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)
What is a void operator
The void operator evaluates the given expression and then returns undefined (i.e, without returning value). The syntax would be as below,
javascript
void expression;
void expression;
Let's display a message without any redirection or reload
javascript
<a href="javascript:void(alert('Welcome to JS world'))">
Click here to see a message
</a>
Note: This operator is often used to obtain the undefined primitive value, using void(0). Also it can be used to call asynchronous functions without waiting for the result.