Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:27:04+00:00 2026-06-12T06:27:04+00:00

After reading both : difference between "void 0 " and "undefined" , https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/void I

  • 0

After reading both :

difference between "void 0 " and "undefined" , https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/void

I still have some questions.

I’ve read that
window.undefined can be overwritten vwhere void operator will return the undefined value always

But the example which caught my eyes was the one in MDN :

<a href="javascript:void(0);">Click here to do nothing</a>

In order to do nothing , I always thought I should write :

href="javascript:return false;"

And this leads me to another question : (at Href context !) :

javascript:void(0); vs javascript:return false;

What is the differences ?

Also – Does

function doWork() {
    return void( 0 );
}

is exactly

function doWork() {

    return undefined;
}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:27:05+00:00Added an answer on June 12, 2026 at 6:27 am

    This will not work properly:

    href="javascript:return false;"
    

    because you are not in a function. You are thinking of this:

    onclick="return false;"
    

    which is correct since return false; is placed in a function. The false value tells the onclick to prevent the default behavior of the element.

    For the return statement to work in an href attribute, you’d need a full function.

    href="javascript:(function() { return false; })();"
    

    but that’s just long and ugly, and as the comments note, JavaScript in an href is generally discouraged.

    EDIT: I just learned something. Having a non undefined expression as above seems to replace the elements with the return value (at least in Firefox). I’m not entirely familiar with the full ramifications of using JavaScript in an href, because I never do it.


    Yes, this:

    return undefined;
    

    returns exactly the same thing this:

    return void 0;
    

    as long as the undefined variable has not been redefined or shadowed by some other value.

    But while they may return the same thing, it’s not entirely accurate to say they are the same thing, because:

    • undefined is a global variable whose default value is the undefined primitive

    • void is an unary operator that will replace the return value of its operand with the undefined primitive

    So they both result in the undefined primitive, but they do so in a very different way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading some excellent posts about the difference between AppDomain.UnhandledException and Application.DispatcherUnhandledException, it appears
After reading answer to this question: Make "make" default to "make -j 8" I
I'm creating new option menu inside fragment but after reading http://developer.android.com/resources/articles/avoiding-memory-leaks.html which said to
After doing a chunk of reading about authenticating users (both here in SO land
After reading monkeytalk faq from http://www.gorillalogic.com/testing-tools/monkeytalk/documentation/monkeytalk-faq : How does it all work? MonkeyTalk is
After reading MSDN-XAML Namespaces and MSDN-Understanding XAML Namespaces , I still do not understand
After reading the Bash man pages and with respect to this post , I
After reading this question, I need to clear up some things. IQueryable<Customer> custs =
after reading the cookbook and various Q&A here I am still a bit confused
After reading jQuery's CSS documentation , it doesn't look like it offers any advantages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.