Say
a=""; // empty String
b=0;
then
a==b; // returns true
What Test could I build to return true only if I pare 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 pare two empty strings or two zero's?
Share Improve this question asked Jan 28, 2015 at 22:18 Bob SBob S 2952 silver badges12 bronze badges 2- 1 here is a really good post of == vs. === stackoverflow./questions/523643/… – taesu Commented Jan 28, 2015 at 22:20
- possible duplicate of Does it matter which equals operator (== vs ===) I use in JavaScript parisons? – Alexis King Commented Jan 28, 2015 at 22:21
2 Answers
Reset to default 8Use the strict parison 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 pare
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745383195a4625325.html
评论列表(0条)