2

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?

2

2 Answers 2

8

Use the strict comparison operator, ===. This will not use JavaScript's default type coercion, so you will get the correct result.

"" === 0; // false
Sign up to request clarification or add additional context in comments.

Comments

1

use === instead of == for checking undifined and zero or false compare

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.