Say
a=""; // empty String
b=0;
then
a==b; // returns true
What Test could I build to return true only if I compare two empty strings or two zero's?
Use the strict comparison operator, ===. This will not use JavaScript's default type coercion, so you will get the correct result.
"" === 0; // false
use === instead of == for checking undifined and zero or false compare
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With