How to use not equal comparison operators (!=, !==) in JavaScript

1 Answer

0 votes
var x = 13;
var y = 5
if (x != y)  // true
    document.write("1. x != y" + "<br />"); 

if (x !== y) // true
    document.write("2. x !== y" + "<br />"); 

x = 13;
y = "5";
if (x != y) // true 
    document.write("3. x != y" + "<br />"); 

if (x !== y) // true
    document.write("4. x !== y" + "<br />"); 
    
x = 13;
y = "13";
if (x != y) // false 
    document.write("5. x != y" + "<br />"); 

if (x !== y) // true // not equal type
    document.write("6. x !== y" + "<br />"); 


  
/*
run:

1. x != y
2. x !== y
3. x != y
4. x !== y
6. x !== y

*/

 



answered Apr 17, 2017 by avibootz
...