Advertisement
728x90
Void(0) is used to prevent the page from refreshing. This will be helpful to eliminate the unwanted side-effect, because it will return the undefined primitive value. It is commonly used for HTML documents that use href="JavaScript:Void(0);" within an <a> element. i.e, when you click a link, the browser loads a new page or refreshes the same page. But this behavior will be prevented using this expression.
For example, the below link notify the message without reloading the page
javascript
1<a href="JavaScript:void(0);" onclick="alert('Well done!')">
2
3Click Me!
4</a>Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 12
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
97of476