What is the meaning of JavaScript void 0?
Answers
You may ocassionally encounter an HTML document that uses href="JavaScript:Void(0);" within an <a> element.
JavaScript void is often used when, inserting an expression into a web page may produce an unwanted side-effect.
By using JavaScript:Void(0), you can eliminate the unwanted side-effect, because it will return the undefinedprimative value.
A common usage of JavaScript:Void(0) is with hyperlinks.
Sometimes, you may need to call some JavaScript from within a link. Normally, when you click a link, the browser loads a new page or refreshes the same page (depending on the URL specified). But you probably don't want this to happen if you've attached some JavaScript to that link.
To prevent the page from refreshing, you could use JavaScript:void(0).
Example of JavaScript:void(0)
We have a link that should only do something (display a message) upon two clicks (a double click). If you click once, nothing should happen. We can specify the double click code by using the ondblclick event handler. To prevent the page reloading upon a single click, we can use JavaScript:void
Answer:
undefined primitive value
Explanation:
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). The void(0) can be used with hyperlinks to obtain the undefined primitive value.