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 9212877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:37:27+00:00 2026-06-18T01:37:27+00:00

Aside from the obvious preventing of links being clicked (with javascript:void(0); ) and for

  • 0

Aside from the obvious preventing of links being clicked (with javascript:void(0);) and for the definition of undefined in many javascript precompiled languages like coffeescript (where undefined becomes void 0) –> What else can the void function be used for?


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

Useful Link: MDN page for void

  • 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-18T01:37:28+00:00Added an answer on June 18, 2026 at 1:37 am

    First, void is an operator, not a function. The answer to your question can’t be given any more clearly than the explanation given in the link to MDN you provided in your question:

    Summary

    The void operator evaluates the given expression and then returns undefined.

    …

    Uses

    This operator allows inserting expressions that produce side effects into places where an expression that evaluates to undefined is desired.

    Theoretical use:

    Change the return value of an expression that produces side effects.

    var i;
    i = 0;       // returns 0
    void i = 1;  // returns undefined
    

    But this use is not very valuable in most situations.

    Practical uses:

    We already know about:

    • Cancel navigation in a bookmarklet
    • Compare item to undefined – Since the global variable undefined could be modified (it is not a reserved word), void 0 is a more reliable way to get an undefined value. Eg: obj.foo === void 0

    Other uses:

    Prevent verbose console output – I use it in a JavaScript console when I only want to execute some code and don’t want to pollute the console with uninteresting verbose output.

    Explicitly pass undefined to a function – It can be useful to know whether a function was called without passing arguments, or whether an argument was passed to a function with a value of undefined:

    function countArguments(a) {
        console.log(a === undefined);
        console.log(arguments.length);
    }
    countArguments();
    countArguments(void 0);
    

    Your console output would be:

    true
    0
    true
    1
    

    Does JavaScript need this operator? Probably not. You can get the same functionality (and more) from a self invoking anonymous function:

    (function(){ /* expression */ })()
    

    But that’s not quite as concise.

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

Sidebar

Related Questions

Aside from the obvious heavy load on the server, is it bad to have
Aside from the obvious (localhost, 127.0.0.1) does PHP (command line interface!) have a mechanism
Aside from the language differences Javascript vs. Objective-J what benefits does Cappuccino provide over
The Question Aside from all the obvious answers, what would cause extension methods to
Aside from scalability issues, has anyone here actually stumbled upon a web-development problem where
Aside from the PEAR repository, which I find often has quite messy code with
Aside from not deploying a Django project to the web site root directory, is
Aside from the official GWT blog, which GWT blogs do you read?
Aside from the GL Support, is there a way to override locale settings with
I have two identical select boxes (aside from their names, of course), and I

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.