Why is it true when comparing with an empty string when the js variable is 0

小主遇到一个bug

                            <ul class="radioUL">
                    <li class=" mR30 editstatus" value="1"><i></i>启用</li>
                    <li class="editstatus" value="0"><i></i>用户禁用</li>
                    </ul>


$(".editstatus").each(function (){
   if($(this).hasClass("act")){
	status=$(this).val();	
    }	
});
if(status == ""){
alert("Please enter a value: ")
}


It is found that when status == 0, the judgment is true.

Summarize the knowledge point:
        In javascript, the variables named below are all false
      var s = "",, i = 0, b = false, n = null, undefined;
      in JavaScript , null, 0, "", false, and undefined are all equal to each other (==) because they all evaluate to 'false

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326994872&siteId=291194637