Navaneeth Krishnan
What is the difference between == & === in javascript?
By Navaneeth Krishnan in JavaScript on Aug 18 2020
  • Cristopher Coronado
    Aug, 2020 19

    == ignores the datatype of variable and === does not it.

    Example:

    1. 4 == "4" => true
    2. 4 === "4" => false
    3. 4 === 4 => true

    • 3
  • Santhosh Kumar Devanga
    Aug, 2020 21

    1. ‘==’ : it does the necessary type conversions before doing the equality comparison.
      Ex:
      1 == ‘1’ => True
      1 == 1 => True
      1 == ‘5’ => False
    2. ‘===’ : it will not do the type conversion hence if the two values are not of the same type, when compared, it will return false

    Ex:
    1 === ‘1’ => False
    1 === 1 => True
    1 === ‘5’ => False

    • 2
  • Jay Krishnareddy
    Aug, 2020 22

    In detail Example

    1. 0 == false // true
    2. 0 === false // false, because they are of a different type
    3. 1 == "1" // true, automatic type conversion for value only
    4. 1 === "1" // false, because they are of a different type
    5. null == undefined // true
    6. null === undefined // false
    7. '0' == false // true
    8. '0' === false // false

    • 1
  • Salman Beg
    Sep, 2020 8

    Check this video which explains clearly,

    https://www.youtube.com/watch?v=S7p9QStPUGo

    Thanks.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS