This can cause problems with things like integers, strings or objects representing booleans or null and undefined variables being equal to strings and integers.
MDN sourced code demonstrating Loose Equality:
var num = 0; var obj = new String('0'); var str = '0'; console.log(num == num); // true console.log(obj == obj); // true console.log(str == str); // true console.log(num == obj); // true console.log(num == str); // true console.log(obj == str); // true console.log(null == undefined); // true // both false, except in rare cases console.log(obj == null); console.log(obj == undefined);
MDN sourced code demonstrating Strict Equality:
var num = 0; var obj = new String('0') var str = '0'; console.log(num === num); // true console.log(obj === obj); // true console.log(str === str); // true console.log(num === obj); // false console.log(num === str); // false console.log(obj === str); // false console.log(null === undefined); // false console.log(obj === null); // false console.log(obj === undefined); // false
Having an explicit conditional statement is often far better than being vague.
Mozilla Developer Network (MDN) has a great write-up on the differences between Strict Equality and Loose Equality. I recommend you go and read it and support them however you can!