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

  • Home
  • SEARCH
  • 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 6711525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:09:02+00:00 2026-05-26T08:09:02+00:00

I am really new to javascript, and stumbled upon the return keyword. Basically, what

  • 0

I am really new to javascript, and stumbled upon the return keyword. Basically, what is the difference in terms of these 2 statements?

<input type="checkbox" onclick="doAlert()" />

vs

<input type="checkbox" onclick="return doAlert();" />

Essentially, both returned the same results and called the function, but is there more to it? Any help greatly appreciated :). 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-05-26T08:09:03+00:00Added an answer on May 26, 2026 at 8:09 am

    Returning false from the function, will abort the effect of the checking. Because the native of functions that written hardcoded into html properties (it became some new local function), writing the html without the word “return” will just run the function, and lose its returning value, as if you’ve wrote:

    function doAlert() {
       if(some_condition)
         return false;
       else
         return true;
    }
    function some_local_function() {
       doAlert();
    }
    

    Function some_local_function won’t return any value, although doAlert returns.

    When you write “return”, it’s like you wrote the second function like this:

    function some_local_function() {
       return doAlert();
    }
    

    which preserves the returning value of doAlert, whatever it will be. If it’s true – the action will perform (the checkbox will be checked) – otherwise – it will cancel.

    You can see live expamle here: http://jsfiddle.net/RaBfM/1/

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

Sidebar

Related Questions

I'm really new to ASP.NET MVC, and I'm trying to integrate some Javascript into
Yo. I'm really quite new to this whole JavaScript business, not to mention AJAX,
I'm really new to HTML, but I can't find anywhere how to return the
Im really really new to Javascript but Ive got this script that loads the
I'm new to javascript/jQuery this really has me stumped. What I'm trying to achieve
I've been using both in javascript ... really don't know the difference. Googling always
I'm not new to JavaScript, but I've never really had too much in-depth knowledge
I'm new into JavaScript and I really like jQuery and hate when it comes
I'm really very new to javascript, and trying to validate a page to xhtml
I'm really new to this and working on a JavaScript code and I want

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.