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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:36:26+00:00 2026-06-12T22:36:26+00:00

In JavaScript, I noticed that []==![] result is true . demo I don’t understand

  • 0

In JavaScript, I noticed that []==![] result is true. demo

I don’t understand this result. Can you explain why?

  • 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-12T22:36:27+00:00Added an answer on June 12, 2026 at 10:36 pm

    [] is an array, but ![] is a boolean value. Whenever you try to compare two objects with different types with == both objects should be transformed into comparable objects (using ToNumber, see step 7. in 11.9.3). This is why [] == ![] yields true, the first empty array gets evaluated to false.

    11.9.3 The Abstract Equality Comparison Algorithm

    The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as
    follows:

    1. […]
    2. If x is null and y is undefined, return true.
    3. If x is undefined and y is null, return true.
    4. If Type(x) is Number and Type(y) is String,
      return the result of the comparison x == ToNumber(y).
    5. If Type(x) is String and Type(y) is Number,
      return the result of the comparison ToNumber(x) == y.
    6. If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
    7. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
    8. If Type(x) is either String or Number and Type(y) is Object,
      return the result of the comparison x == ToPrimitive(y).
    9. If Type(x) is Object and Type(y) is either String or Number,
      return the result of the comparison ToPrimitive(x) == y.
    10. Return false.

    However, if you use the strict type comparison operator === the result is false, since both types differ:

    11.9.6 The Strict Equality Comparison Algorithm

    The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed
    as follows:

    1. If Type(x) is different from Type(y), return false.
    2. If Type(x) is Undefined, return true.
    3. If Type(x) is Null, return true.
    4. If Type(x) is Number, then
      1. If x is NaN, return false.
      2. If y is NaN, return false.
      3. If x is the same Number value as y, return true.
      4. If x is +0 and y is -0, return true.
      5. If x is -0 and y is +0, return true.
      6. Return false.
    5. If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and
      same characters in corresponding positions); otherwise, return false.
    6. If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.
    7. Return true if x and y refer to the same object. Otherwise, return false.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was playing around with some Javascript snippets today and noticed that this code
I noticed that JavaScript's new Date() function is very smart in accepting dates in
I've noticed that initial comment in JavaScript or CSS files is sometimes started with
I noticed that an application I am maintaining was giving me a javascript error
I've noticed that many pages with heavy javascript load certain files at the end
I have recently noticed that a lot of JavaScript files on the Web start
When working on some Javascript for a web application, I noticed that I had
While creating JavaScript with ASP.NET MVC I noticed several scope warnings and realized that
I am doing some exercises in my object-oriented javascript book, I notice that this:
I have noticed that, from Google Maps page, you can get an embed link

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.