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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:02:06+00:00 2026-06-15T02:02:06+00:00

JavaScript has different equality comparison operators Equal == Strict equal === It also has

  • 0

JavaScript has different equality comparison operators

  • Equal ==
  • Strict equal ===

It also has a logical NOT ! and I’ve tended to think of using a double logical NOT, !!x, as basically the same as true == x.

However I know this is not always the case, e.g. x = [] because [] is truthy for ! but falsy for ==.

So, for which xs would (true == x) === !!x give false? Alternatively, what is falsy by == but not !! (or vice versa)?

  • 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-15T02:02:08+00:00Added an answer on June 15, 2026 at 2:02 am

    “So, for which xs would (true == x) === !!x give false?”

    Any x where its Boolean conversion is not the same as its conversion by the Abstract Equality Comparison Algorithm.


    An example is a string with only whitespace:

    var x = " ";
    

    Its Boolean conversion is true (as is the case with any non-empty string), but its == comparison is false because a string with only white space will be converted to the number 0, and the true value will be converted to the number 1, and those values are not equal.

    x == true; // false
    !!x;       // true
    

    or to show the ultimate values the == is comparing:

    Number(true) == Number(x);
     //      1   ==        0
    
    1 == 0; // false
    

    and to show the result of !!x, it would be equivalent to this:

    Boolean(x);  // true
    

    So your original expression could crudely be seen as the following:

       var x = " ";
    
       (Number(true) == Number(x)) === Boolean(x);
    // (         1   ==        0 ) ===        true
    //                   ( false ) ===        true
    
       false === true; // false
    

    I say “crudely” because this certainly doesn’t capture all the detail of the algorithm linked above, and won’t be the same for all values provided to the operands.

    To understand how == treats its operands, you really need to study the algorithm a bit.

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

Sidebar

Related Questions

I've been doing testing work in Python using QtWebkit/Spynner. As QtWebKit has Javascript support
I was wondering why JavaScript has such a confusing API. It is not consistent
I'm using javascript and jQuery. I have a problem that my web app has
I'm implementing a service that has several different ways it can be accessed: Using
I'm building a grid where each box has a different color value using HTML
Javascript has a poorly constructed but convenient arguments variable inside every function, such that
The following JavaScript has some unwanted behaviour: <html> <script> function AddEventListener(el, listener) { el.addEventListener
I was baffled today when someone mentioned on a group that Javascript has evolved
As per http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf , JavaScript has 6 types: undefined , null , boolean ,
I read that the javascript language has characteristics that assist in the implementation of

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.