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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:40:56+00:00 2026-05-15T11:40:56+00:00

Possible Duplicates: What does this expression mean “!!” What does the !! operator (double

  • 0

Possible Duplicates:
What does this expression mean “!!”
What does the !! operator (double exclamation point) mean in JavaScript?

Here is a snippet from Prototype Javascript Library :

  Browser: (function(){
    var ua = navigator.userAgent;
    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
    return {
      IE:             !!window.attachEvent && !isOpera,
      Opera:          isOpera,
      WebKit:         ua.indexOf('AppleWebKit/') > -1,
      Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
      MobileSafari:   /Apple.*Mobile/.test(ua)
    }
  })(),

This is all good and i understand the objective of creating a browser object. One thing that caught my eye and I haven’t been able to figure out is the use of double not operator !! in the IE property.

If you read through the code you will find it at many other places. I dont understand whats the difference between !!window.attachEvent and using just window.attachEvent.

Is it just a convention or is there more to it that’s not obvious?

  • 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-15T11:40:56+00:00Added an answer on May 15, 2026 at 11:40 am

    I dont understand whats the difference between !!window.attachEvent and using just window.attachEvent.

    The key of understanding this, is to know that the Boolean Logical Operators can return an operand, and not a Boolean result necessarily:

    The Logical AND operator (&&), will return the value of the second operand if the first is truly:

    true && "foo"; // "foo"
    

    And it will return the value of the first operand if it is by itself falsy:

    undefined && "anything"; // undefined
    NaN && "anything";       // NaN
    0 && "anything";         // 0
    

    So, in the snippet !!window.attachEvent && !isOpera, we already know that isOpera is a boolean value, !! will just make sure that Browser.IE is a boolean result also.

    An example: let’s say we are in Firefox, window.attachEvent is undefined and !isOpera is true, if you don’t use the double negation, Browser.IE would be undefined instead false.

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

Sidebar

Related Questions

Possible Duplicates: myVar = !!someOtherVar What does the !! operator (double exclamation point) mean
Possible Duplicates: Reference - What does this symbol mean in PHP? what do “=&”
Possible Duplicates: What does “=>” mean in PHP? Reference - What does this symbol
Possible Duplicates: What does this JavaScript snippet mean? Location of parenthesis for auto-executing anonymous
Possible Duplicate: JavaScript losing “this” object reference with private/public properties Why does the second
Possible Duplicates: In Javascript, what does it mean when there is a logical operator
Possible Duplicates: Why does StyleCop recommend prefixing method or property calls with “this”? When
Possible Duplicates: What does “static” mean in a C program? Static vs global What
Possible Duplicates: What does this mean? (function (x,y)){…}){a,b); in JavaScript What do parentheses surrounding
Possible Duplicates: What does the PHP syntax $var1->$var2 mean? Reference - What does this

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.