What does javascript void 0 mean

0 votes
<a href="javascript:void(0)" id="loginlink">login</a>

Such hrefs have been encountered several times, but I am unsure of their exact meaning.

Sep 19 in Java-Script by Tejashwini
• 540 points
21 views

1 answer to this question.

0 votes
After evaluating the provided expression, the void operator returns undefined.

To obtain the undefined primitive value, the void operator is frequently used, typically with "void(0)" (which is identical to "void 0"). In these circumstances, using the global variable undefined is a better option (assuming it has not been assigned to a non-default value).

Here is an explanation: void operator.

You would want to accomplish this using a link's href because, by default, a javascript: URL will take the browser to a plain text version of the output of that JavaScript's evaluation. The browser, however, remains on the same page if the outcome is undefinable. A brief, straightforward script, void(0), evaluates to undefined.
answered Sep 20 by Abhinaya
• 1,160 points

Related Questions In Java-Script

0 votes
0 answers

in java what does the @ symbol mean?

I am aware of what it implies ...READ MORE

4 days ago in Java-Script by Abhinaya
• 1,160 points
8 views
0 votes
1 answer

What is callback function in JavaScript?

callback is not a keyword, its just ...READ MORE

answered Jan 30, 2020 in Java-Script by Niroj
• 82,780 points
11,309 views
0 votes
1 answer

What is an appropriate content-type header for JavaScript files?

Hello @kartik, JS has two registered MIME types:  The ...READ MORE

answered Jul 7, 2020 in Java-Script by Niroj
• 82,780 points
1,271 views
0 votes
1 answer

What is the “hasClass” function with plain JavaScript?

Hello @Kartik, Simply use classList.contains(): if (document.body.classList.contains('thatClass')) { ...READ MORE

answered Sep 2, 2020 in Java-Script by Niroj
• 82,780 points
351 views
0 votes
0 answers

What does "javascript:void(0)" mean?

<a href="javascript:void(0)" id="loginlink">login</a> ...READ MORE

Sep 20 in Java by Nicholas
• 6,240 points
13 views
0 votes
1 answer

Presenting docket dtates inside html page by javascript

Use the Docker Engine Api:Docker Engine API ...READ MORE

answered Jun 20, 2018 in Docker by DareDev
• 6,890 points
236 views
0 votes
1 answer

Migrating proxy npm repo in nexus 3

I don't think you can achieve this ...READ MORE

answered Jun 22, 2018 in DevOps Tools by DareDev
• 6,890 points
839 views
+1 vote
1 answer

What is the difference between JavaScript and Java

This quote rightly explains that 2 totally ...READ MORE

answered Jun 29, 2018 in Java by Daisy
• 8,120 points
261 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP