What is the difference between the loose and the strict equality operator?
Strict equality compares both the type and the value, and it never converts anything. Loose equality converts one or both of the values to a common type first, and then compares them. The two operators run at about the same speed, and that is not the reason to pick one of them. The strict operator is easy to predict, while the loose one asks you to remember a conversion table every time you read it.
console.log(1 == '1'); // true - the text becomes a number
console.log(1 === '1'); // false - the types are different
console.log(0 == ''); // true - both become 0
console.log(0 === ''); // false
console.log(null == undefined); // true - this is a special rule
console.log(null === undefined); // false
console.log(NaN == NaN); // false
console.log([] == false); // true - the array becomes '' and then 0
The loose operator has a defined conversion order, and it is worth memorising for the one or two places where you will meet it. If both values already have the same type, it behaves like strict equality. If one of them is null and the other is a value that was never assigned, they are equal. Otherwise the engine turns the value that is not an object into a number and compares the numbers. That last step explains the strange results. An empty array becomes an empty string, which becomes zero, and the text "false" becomes a number, which is not a number at all, so that comparison is false.
Strict equality avoids all of that because it never converts. A number is never equal to a text that happens to spell the same digits, and two different objects are never equal to each other no matter how similar they look.
The exception worth knowing is that strict equality still uses object identity for objects and arrays. Two separately created empty arrays are not equal, even though both of them have no elements at all.