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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:54:22+00:00 2026-05-30T03:54:22+00:00

I was just experimenting and tried putting this in the console: 4 | 2

  • 0

I was just experimenting and tried putting this in the console:

4 | 2 | 4 | 1 | 10

returns 15 in console..

4 | 2 | 4 | 3 | 1

returns 7 in console..

I tried that on Chrome and Firefox.

Why?

I’m just starting with learning JavaScript… maybe I’m missing a concept here?

  • 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-30T03:54:24+00:00Added an answer on May 30, 2026 at 3:54 am

    The | operator in JavaScript is a bitwise integer OR operator. So it’s doing an OR operation on the bits you’re giving it, resulting in 15.

    A bitwise OR operation takes each bit in the value and sets the corresponding bit in the result if either of the input bits in that position is set. So

    4  is 0100 in binary
    2  is 0010
    4  is 0100
    1  is 0001
    10 is 1010
          ----
          1111 = 15 decimal

    Update: In a comment on your question, you’ve said you were expecting true rather than 15. If so, you want the logical OR operator, ||, not the bitwise operator, although || may also surprise you with what it returns (4 || 2 || 4 || 1 || 10 = 4, not true), as JavaScript’s logical OR (||) is curiously powerful, more so than in many other languages.

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

Sidebar

Related Questions

I just started experimenting with Aptana Jaxer server side javascript engine for my next
I've just been experimenting with a CSS tooltip that fades in with CSS3's transitions.
I just started experimenting with java today (have experience with javascript and PHP) and
I'm learning Google App Engine and experimenting with an application that does a lot
I'm just experimenting with boost::pool to see if its a faster allocator for stuff
I've just been experimenting with the boost::function_types library recently, and I've come across a
I've just started experimenting with WPF templates vs. styles and I'm not sure what
Hi I've just started experimenting with .live and .die and having some great results
I've been searching and experimenting for nearly four hours now, so I'm gonna just
Just to make sure I'm understanding shallow copies of reference types correctly and that

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.