DEV Community

Cover image for Understanding == comparison operator in JavaScript
Akash bhandwalkar
Akash bhandwalkar

Posted on • Updated on

Understanding == comparison operator in JavaScript

In JavaScript there are two operator you can use to compare values == and ===.

Let's understand few examples of == to understand how it works.

Algorithm of ==

  1. If one of the operands is Object and other is not return false
  2. If both operands are Object if reference is not same, return false
  3. If One of the operands is NaN returns false
  4. Check if Operands can be converted to Same primitive types and then compare.

Top comments (0)