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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:49:44+00:00 2026-06-08T02:49:44+00:00

just a quick question. I cannot find anything relating to this since I don’t

  • 0

just a quick question. I cannot find anything relating to this since I don’t really see how to explain it… but, if I combine two bool values using an && to make another variable, what will happen?

var is_enabled = isEnabled() && isSupported();

If isEnabled() is false and isSupported() is true, will it equal false?

  • 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-08T02:49:46+00:00Added an answer on June 8, 2026 at 2:49 am

    In Javascript the && and || operators are slightly strange. It depends on if the value is “falsy” (zero, undefined, null, empty string, NaN) or truthy (anything else, including empty arrays).

    With && if the first value is “falsy”, then the result of the operation will be the first value, otherwise it will be the second value. With || if the first value is “falsy” then the result of the operation will be the second value, otherwise it will be the first value.

    Example:

    var a = 5 && 3; // a will be 3
    var a = 0 && 7; // a will be 0
    
    var a = 1 || 2; // a will be 1
    var a = 0 || 2; // a will be 2
    

    This is very useful if you want to replace this:

    if (x == null){
      x = 5;
    }
    

    With:

    x = x || 5;
    

    So in short, if isEnabled() is truthy then is_enabled will be set to whatever isSupported() returns. If isEnabled() is falsy, then is_enabled will be set to whatever that falsy value is.

    Also as Robert pointed out, there is short-circuiting:

    var x = 5 || infinite_loop();
    var x = false && infinite_loop();
    

    In both cases, the infinite_loop() call doesn’t happen, since the two operations are short-circuited – || doesn’t evaluate the second value when the first value is truthy, and && doesn’t evaluate the second value when the first value is falsy.

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

Sidebar

Related Questions

just a quick question, was trying different ways to accomplish this, but ended with
just a quick question. For some reason i cannot see the default web parts
Just a quick question, I'm getting the idea that you don't. Why is this,
Just a quick question, on which I cannot find a good reference, especially with
Just a quick question, that I cannot fathom out, hope you guys and girls
This may have been answered before, but I cannot find a solution that works.
Just a quick simple question that I can not seem to find an answer
Just a quick question. I cant find it in the documentation. If I use
Just a quick question, how do I get pypy to recognize third pary modules
Just a quick question.. Following opening a text file in a separate definition (no

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.