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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:41:33+00:00 2026-05-28T02:41:33+00:00

jsbin started warning me that x != ” is not good, and I should

  • 0

jsbin started warning me that x != '' is not good, and I should replace it with x !== ''

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-05-28T02:41:34+00:00Added an answer on May 28, 2026 at 2:41 am
    var x = false;
    console.log(x !== ''); //true
    console.log(x != ''); //false
    

    In other words, false (and other falsy values, like 0) will coerce to an empty string. The !== and === operators (strict equality operators) ensure that the things being compared are of the same type.


    To expand upon why this is the case, you need to head to the spec (linked to by T.J. Crowder in the comments). The section on the “Abstract Equality Comparison Algorithm” tells us the following:

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

    The section on ToNumber tells us:

    The result is 1 if the argument is true. The result is +0 if the
    argument is false.

    In the example above, the argument is false, so we are now comparing +0 != ''. When comparing a number to a string, the following rule is followed:

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

    Calling ToNumber on an empty string results in +0, just as it did for false:

    A StringNumericLiteral that is empty or contains only white space is
    converted to +0.

    Now we are comparing +0 != +0, so we enter the “x and y are of the same type” section, which tells us:

    If x is the same Number value as y, return true.

    So +0 is equal to +0 and since we are using != it returns false.

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

Sidebar

Related Questions

EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
http://jsbin.com/uremuc/2/edit If I'm choosing jquery 1.5.2 in jsBin , running .attr('tagName') should return me
I have this HTML and CSS http://jsbin.com/uciya5/3/edit where the problem is that the radio
http://jsbin.com/ofojis/edit#preview http://jsbin.com/ofojis/edit#source Why is the top border of this inline element not displaying? Adding
Very simple example: http://jsbin.com/ohude Click button1, the 'hello2' text p should change z-index to
Here's a sample: http://jsbin.com/idepo/5 The padding and everything seems to look better when not
http://jsbin.com/uqafo4 Please check the white area: it should go all the way, as I
EXAMPLE: http://jsbin.com/ewiko4/5/ So I have some Dynamic divs that I need to figure out
I found this test http://jsbin.com/ekofa/2 that shows that HTML5 data-XXX is faster then jQuery
I have the following code: http://jsbin.com/egiju4 That works a treat on FF and chrome,

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.