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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:06:12+00:00 2026-06-13T16:06:12+00:00

Can anyone please explain how this line works. a & 3 || (b, c)

  • 0

Can anyone please explain how this line works.

 a & 3 || (b, c)

Does the first part translate to:

 a = a & 3;

or is that a ternary code and if true b is returned, else c? 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-06-13T16:06:14+00:00Added an answer on June 13, 2026 at 4:06 pm

    (Note on terminology: In 1 + 2, 1 and 2 are “operands” and + is an “operator”)

    The first operator in that expression (&) is a bitwise ‘and’: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators

    The second operator (||) is a logical ‘or’, which returns the first operand if it’s truthy (if it would pass an if check), and the second one otherwise.

    The third one (,) is the comma operator, which simply returns the second operand.

    So, in plain English: Take the bitwise ‘and’ of a with 3 (which is 11 in binary), meaning that the resulting value will be one of 0, 1, 2, or 3 depending on the value of the first two bits in a. If it is not zero, return that value. Otherwise, return c, but b will also be evaluated.

    For example, if a is 2, then a & 3 will be 10 & 11 == 10 (since 1 & 1 == 1 and 0 & 1 == 0), which is 2 and truthy (the only falsy number is 0 or 0.0), so that will be the return value of the whole expression, and b and c will not even be evaluated. On the other hand, if a is 4, then a & 3 will be 100 & 11 == 000, which is falsy, so (b, c) will be evaluated and the result will be that c is the return value.

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

Sidebar

Related Questions

Can anyone please explain exactly how the following code works, line by line. I'm
As the title - please can anyone explain how the next scripts works this
Can anyone please explain this code? This example is taken from javascript.info. I don't
Can anyone please explain how this works #define maxMacro(a,b) ( (a) > (b) )
Can anyone please explain exactly what this code and its components are doing? I
Can anyone please explain to me whats wrong with this piece of code and
My first time using triggers. Can anyone please explain why this trigger won't work?
can anyone please explain this code? #include <avr/io.h> #include <avr/interrupt.h> #include <avr/signal.h> char n
Can anyone please explain me what delegateEvents in backbone.js does? The documentation did not
Can anyone please explain why the following code behaving strangely: public class UserInputTest {

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.