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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:37:46+00:00 2026-06-14T13:37:46+00:00

From the Google Chrome console: var x = null; undefined x > 0 false

  • 0

From the Google Chrome console:

var x = null;
undefined
x > 0
false
x < 0
false
x > -1
true
x < 1
true
x == 1
false
x === 1
false
  • 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-14T13:37:47+00:00Added an answer on June 14, 2026 at 1:37 pm

    When you compare null for equality to 0, the result is false. If you force null to be interpreted in a numeric context then it is treated like 0 and the result becomes true.

    You can force it to be numeric by putting + in front, or by using numeric operators like <, <=, >, and >=. Notice how null >= 0 and null <= 0 are both true.

    > null == 0
    false
    > +null == 0
    true
    > null >= 0
    true
    > null <= 0
    true
    

    The ECMAScript Language Specification defines when a so-called “ToNumber” conversion is performed. When it is, null and false are both converted to 0.

    §9.1 Type Conversion and Testing:

    Table 14 — To Number Conversions

    Argument Type     Result
    -------------     ------
    Undefined         Return NaN
    Null              Return +0
    Boolean           Return 1 if argument is true. Return +0 if argument is false.
    Number            Return argument (no conversion).
    String            See grammar and note below.
    

    Knowing when the ToNumber conversion is applied depends on the operator in question. For the relational operators <, <=, >, and >= see:

    §11.8.5 The Abstract Relational Comparison Algorithm:

    The comparison x < y, where x and y are values, produces true, false,
    or undefined (which indicates that at least one operand is NaN). Such
    a comparison is performed as follows:

    1. Call ToPrimitive(x, hint Number).

    2. Call ToPrimitive(y, hint Number).

    3. If Type(Result(1)) is String and Type(Result(2)) is String, go to step 16. (Note that this step differs from step 7 in the algorithm for
      the addition operator + in using and instead of or.)

    4. Call ToNumber(Result(1)).

    5. Call ToNumber(Result(2)).

    The == operator is different. Its type conversions are described below. Notice how null and false follow different rules.

    §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. If Type(x) is different from Type(y), go to step 14.

    …

    14. If x is null and y is undefined, return true.

    15. If x is undefined and y is null, return true.

    16. If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).

    17. If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.

    18. If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.

    19. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).

    20. If Type(x) is either String or Number and Type(y) is Object, return the result of the comparison x == ToPrimitive(y).

    21. If Type(x) is Object and Type(y) is either String or Number, return the result of the comparison ToPrimitive(x) == y.

    22. Return false.

    If you read carefully you can see why false == 0 is true but null == 0 is false.

    • For false == 0, Type(x) is Boolean. This means Step 18’s type conversion is applied, and false is converted to a number. ToNumber(false) is 0, and 0 == 0 is true, so the comparison succeeds.

    • For null == 0, Type(x) is Null. None of the type checks match so the comparison falls through to Step 22, which returns false. The comparison fails.

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

Sidebar

Related Questions

Working in Firebug Console, but not from file. Google Chrome - Uncaught TypeError: Object
Here is a question in JavaScript below: // Tested via Google Chrome console. var
Google Chrome and Firefox deduces the response from the server without problems why doesn't
I had recently (and unfortunately) uninstalled the google chrome browser from my computer -while
On Google Analytics, I'm not seeing my custom tracking event from within my chrome
Possible Duplicate: Where to read console messages from background.js in a Chrome extension? I
I'm very new to chrome extension development.. I got basic idea from google's tutorial
The error When the user opens http://sync.aws.af.cm/ , the Google Chrome JavaScript Console shows
Im switching from firebug to Google Chrome developer tools. I like it so far,
Searching from google.com, like www.abc.com Search Result Rank the pages like Title..... Description... www.abc.com

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.