When you click on the above link. Even though the code within it specifies to display a message in an alert box (and this action does take place), the page will reload automatically.
When you run the above example, you can see a message is displayed in an alert box as intended and void(0) prevents the page from reloading . So the void operator can be useful when you need to call another function that may have otherwise resulted in an unwanted page refresh.
- What is noscript tag?
- Difference between '=', '==' and '===' operators?
- What is Browser Object Model
- How to test a string as a literal and as an object ?
- What is Associative Array? How do we use it?
- What's the Difference Between Class and Prototypal Inheritance?
- Event bubbling and Event Capturing in JavScript?
- What is the difference between .call() and .apply()?
- What is an immediately-invoked function expression?
- What Are RESTful (REpresentational State Transfer)Web Services?