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?
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