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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:06:50+00:00 2026-05-15T21:06:50+00:00

In Python, and maybe in Javascript, the boolean or and and operators return one

  • 0

In Python, and maybe in Javascript, the boolean or and and operators return one of the operands, instead of true or false.

  • In Python, one of the operands is returned: '' || 'hello' == 'hello'
  • In comparison, in PHP: '' || 'hello' == true;

Now,

  • How is this behavior of boolean operators called?
  • Does this also work in Javascript in all browsers?
  • 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-15T21:06:50+00:00Added an answer on May 15, 2026 at 9:06 pm

    As Ignacio’s answer points out, these are coalescing operators. || is the null coalescing operator, && is the null-safe coalescing operator (link to follow, if I can find one sorry, I can’t find a link).

    They should be available in all browsers – they are both defined in the ECMA-262 1st, 2nd, 3rd and 5th editions, most current Javascript implementations are based upon 3rd or 5th. From ECMA-262 3rd edition:

    The production LogicalANDExpression : LogicalANDExpression && BitwiseORExpression is evaluated as
    follows:
    1. Evaluate LogicalANDExpression.
    2. Call GetValue(Result(1)).
    3. Call ToBoolean(Result(2)).
    4. If Result(3) is false, return Result(2).
    5. Evaluate BitwiseORExpression.
    6. Call GetValue(Result(5)).
    7. Return Result(6).

    The production LogicalORExpression : LogicalORExpression || LogicalANDExpression is evaluated as
    follows:
    1. Evaluate LogicalORExpression.
    2. Call GetValue(Result(1)).
    3. Call ToBoolean(Result(2)).
    4. If Result(3) is true, return Result(2).
    5. Evaluate LogicalANDExpression.
    6. Call GetValue(Result(5)).
    7. Return Result(6).

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

Sidebar

Related Questions

Maybe I'm spoiled by Python, but does Octave allows one to assign the values
I am looking for a pure Javascript/Python upload example, that uses server polling instead
I'm just starting on Python and maybe I'm worrying too much too soon, but
I'm new to Python's iterators, so maybe my language is not always correct. I
Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is
Can anyone direct me to a good Python screen scraping library for javascript code
Do you know of a syntax parser module (written in Ruby, Python, Javascript...) that,
Possible Duplicate: Why there are no ++ and — operators in Python? This question
I am Python newbie, so maybe don't knew if this is obvious or not.
Is there an analogue of this tool (maybe python/ruby/etc) which runs under windows? It

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.