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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:27:34+00:00 2026-05-13T06:27:34+00:00

In javascript, when using an if statement with multiple conditions to test for, does

  • 0

In javascript, when using an if statement with multiple conditions to test for, does javascript test them all regardless, or will it bail before testing them all if it’s already false?

For example:

 a = 1
 b = 2
 c = 1

 if (a==1 && b==1 && c==1)

Will javascript test for all 3 of those conditions or, after seeing that b does not equal 1, and is therefore false, will it exit the statement?

I ask from a performance standpoint. If, for instance, I’m testing 3 complex jQuery selectors I’d rather not have jQuery traverse the DOM 3 times if it’s obvious via the first one that it’s going to return FALSE. (In which case it’d make more sense to nest 3 if statements).

ADDENDUM: More of a curiosity, what is the proper term for this? I notice that many of you use the term ‘short circuit’. Also, do some languages do this and others dont?

  • 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-13T06:27:34+00:00Added an answer on May 13, 2026 at 6:27 am

    The && operator “short-circuits” – that is, if the left condition is false, it doesn’t bother evaluating the right one.

    Similarly, the || operator short-circuits if the left condition is true.

    EDIT: Though, you shouldn’t worry about performance until you’ve benchmarked and determined that it’s a problem. Premature micro-optimization is the bane of maintainability.

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

Sidebar

Related Questions

I have a Javascript question that I am curious about. When using: var test
I'm trying to convert an if statement into a switch statement using javascript. This
How to execute an INSERT statement using a javascript ADODB.Recordset object? This is the
the website in the main document includes a javascript file using the following statement:
so right now I'm writing a Windows 7 Gadget using Javascript (w/HTML) that will
I'm writing a quick website in ASP (classic) Javascript. I'm using a prepared statement
How to check class name using javascript?? I am using this statement.. if (document.getElementByClass(expandable)
A few days ago I posted this question: switch statement and loops using jquery/javascript
using javascript I have a function function test(variable) { if(variable != 'undefined') { console.log('variable
I'm using javascript, jQuery and regex to add anchors (#hashtag) around all hashtags on

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.