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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:12:03+00:00 2026-05-15T23:12:03+00:00

I have a function: function myfunction() { if (a == ‘stop’) // How can

  • 0

I have a function:

function myfunction() {
  if (a == 'stop')  // How can I stop the function here?
}

Is there something like exit() in JavaScript?

  • 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-15T23:12:04+00:00Added an answer on May 15, 2026 at 11:12 pm

    You can just use return.

    function myfunction() {
         if(a == 'stop') 
             return;
    }
    

    This will send a return value of undefined to whatever called the function.

    var x = myfunction();
    
    console.log( x );  // console shows undefined
    

    Of course, you can specify a different return value. Whatever value is returned will be logged to the console using the above example.

    return false;
    return true;
    return "some string";
    return 12345;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a for loop that I want to exit like this: function MyFunction()
I try to do something like that 1. <head><% out.println(<script type=\text/javascript\>); out.println(function myfunction(){); out.println(for(int
I have a function like this: MyFunction(double matrix[4][4]) {/*do stuff*/} I am calling this
I have some code like this: var content = document.getElementById('myDivId'); function MyFunction() { alert(content.style.height);
I have this javascript function myFunction(source) { window.open(source, Title, 'width=400, height=400'); } and in
I have a function that is like this - var myFunction = function(arg1, arg2,
I have a PHP function that returns something: function myfunction() { $array = array('one',
I have a function(myFunction) with parameter v, I hope it can return different object
I have an interface like Public Shared Function myfunction(Byval myvar as string, Optional ByVal
I have a JQuery function: function MyFunction() { //I need a command here to

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.