What is the meaning of JavaScript void 0?


The void operator is used to evaluate the given expression. After that, it returns undefined. It obtains the undefined primitive value, using void(0).

If inserting an expression into a web page results in unwanted effect, then use JavaScript void to remove it. Adding JavaScript:Void(0), returns the undefined primitive value.

The void operator is used to evaluate the given expression. After that, it returns undefined. It obtains the undefined primitive value, using void(0).

We used JavaScript:void(0) above to prevent the page from reloading when the button is clicked the first time.
It only works when the button will be clicked twice. If it is clicked once, then nothing happens. But the alert box comes over when the button is clicked twice since we used the ondblclick event handler.

Updated on: 30-Jul-2019

187 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements