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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:29:22+00:00 2026-05-17T20:29:22+00:00

What does this JavaScript code mean? flag &= ~CONST Is it append, prepend, intersection

  • 0

What does this JavaScript code mean?

flag &= ~CONST

Is it append, prepend, intersection or something else?

  • 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-17T20:29:23+00:00Added an answer on May 17, 2026 at 8:29 pm

    This will turn off whatever constant represents.

    For example, lets look at a hypothetical example of code which would represent the state of a window:

    WS_HASBORDER           = 0x01;
    WS_HASCLOSEBUTTON      = 0x02;
    WS_HASMINIMIZEBUTTON   = 0x04;
    WS_HASMAXIMIZEBUTTON   = 0x08;
    WS_ISMAXIMIZED         = 0x10;
    

    We could represent the “state” of the window by using
    windowState = WS_HASBORDER | WS_HASCLOSEBUTTON | ... etc

    now, lets say we want to “turn off” one of these states, well, thats what your example code does…
    windowState &= ~WS_HASBORDER

    Now what the above code does, is it gets the compliment [i guess you could call it the inverted bits] of whatever is to its right, WS_HASBORDER.

    So.. WS_HASBORDER has one bit turned on, and everything else is turned off. Its compliment has all bits turned on, except for the one bit that was turned off before.

    Since I’ve represented the many constants as bytes, i’ll just show you an example [not that javascript doesn’t represent numbers as bytes, nor can you do so]

    WS_HASBORDER           = 0x01; //0000 0001
    WS_HASCLOSEBUTTON      = 0x02; //0000 0010
    WS_HASMINIMIZEBUTTON   = 0x04; //0000 0100
    WS_HASMAXIMIZEBUTTON   = 0x08; //0000 1000
    WS_ISMAXIMIZED         = 0x10; //0001 0000
    

    _ now for an example

    windowState = WS_HASBORDER | WS_HASCLOSEBUTTON | WS_HASMINIMIZEBUTTON |
                  WS_HASMAXIMIZEBUTTON | WS_ISMAXIMIZED;
    
         0000 0001
         0000 0010
         0000 0100
         0000 1000
    and) 0001 0000
    --------------
         0001 1111 = 0x1F
    

    So… windowState gets the value 0x1F

    windowState &= ~ WS_HASMAXIMIZEBUTTON

     WS_HASMAXIMIZEBUTTON: 0000 1000  
    ~WS_HASMAXIMIZEBUTTON: 1111 0111
    

    ..To finish our calculation

                 windowState
    &) ~WS_HASMAXIMIZEBUTTON
    
    becomes
        0001 1111
    &)  1111 0111
    -------------
        0001 0111 = 0x07
    

    Here are your resulting flags:
    On:
    WS_HASBORDER
    WS_HASCLOSEBUTTON
    WS_HASMINIMIZEBUTTON
    WS_ISMAXIMIZED

    Off:
    WS_HASMAXIMIZEBUTTON

    Hope that helps. Back to procrastinating homework I go! haha.

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

Sidebar

Related Questions

What does this mean exactly? I'm doing something like this: File.Copy(@\\foo\bar\baz.txt, @c:\test\baz.txt); MSDN doesn't
What does this bat code do? for /f %%i in ('dir /b Client\Javascript\*_min.js') do
See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
Why does this javascript return 108 instead of 2008? it gets the day and
Why does this code fail to display the category name Apples using the current
Why does this code: class A { public: explicit A(int x) {} }; class
Actually that's it. What does this error mean? I've googled on it, but found
Possible Duplicates: What does this expression mean “!!” What does the !! operator (double
I came across this problem when referring a piece of JavaScript code: <a href="javascript:void(0);"><!--
I have this piece of code: <script language=javascript type=text/jscript> document.write(<img src='http://dm.leadgenesys.com/jpgp.lgt?en=P.........TP_Q=&amp;ur=' + escape(document.referrer) +

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.