Advertisement
728x90
The void operator evaluates the given expression and then returns undefined (i.e, without returning value). The syntax would be as below,
javascript
1void expression;
2
3void expression;Let's display a message without any redirection or reload
javascript
1<a href="javascript:void(alert('Welcome to JS world'))">
2 Click here to see a message
3 </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.
Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 44
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
300of476