5

When a == b is true after initialize these

var a = 10, b = "10.0";

Comments
  • 1
    ... then you're using Perl
  • 0
    @ac1235 i don't know about perl but i was referring javascript
  • 1
    @harrizsb
    Types and values are not checked the same way in JavaScript as they are in other languages.

    In JS, you must use the "===" operator to check value _and_ type.

    Technically, at least from the programmers perspective, "10" and 10 hold the same _value_ but they are different types(string and int).

    The "==" operator checks only the type.

    So yes, this is true:
    "10.0" == 10
    But this is not:
    "10.0" === 10

    Keep in mind that this is also true:
    10.0 === 10

    This "quirk" can be quite useful at times. But you must know that it exists.

    There are many subtleties in JS.
    This is one of them 😉
  • 1
    @coolq yup i did know that but i was inspired by how strict javascript is, which make my eyes keep open for this kind of thing
  • 1
    @harrizsb
    Okay, just making sure 😉
Add Comment