What is the meaning of JavaScript void 0?

JavascriptWeb DevelopmentFront End Technology

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.

raja
Published on 07-Feb-2018 13:55:05
Advertisements