Comparison Operators


JavaScript comparison operator compares the two operands and return Boolean value true or false.

1. == (is equals to)

document.write(10 == 4);
// prints false

document.write(10 == 10);
// prints true

2. === (Identical (equals and of same type))

document.write(10 === "10");
// prints false

document.write(10 === 10);
// prints true

3. != (not equals to)

document.write(10 != 4);
// prints true

document.write(10 != 10);
// prints false

4. !== (Not Identical)

document.write(10 !== "10");
// prints true

document.write(10 !== 10);
// prints false

5. > (Greater than)

document.write(10 > 20);
// prints true

document.write(10 > 10);
// prints false

6. >= (Greater than or equals to)

document.write(10 >= 10);
// prints true

document.write(10 >= 5);
// prints false

7. < (Less than)

document.write(10 < 20);
// prints true

document.write(10 < 5);
// prints false

8. <= (Less than or equals to)

document.write(10 <= 10);
// prints true

document.write(10 <= 5);
// prints false