js 假值

        function demo(a){
			if(a){
				console.log(111);
			}else{
				console.log(222);
			}
		}
demo(0)
html_dom.html:27 222
undefined
demo(false)
html_dom.html:27 222
undefined
demo('')
html_dom.html:27 222
undefined
demo(-3)
html_dom.html:25 111
console.log( false == null )      // false
console.log( false == undefined ) // false
console.log( false == 0 )         // true
console.log( false == '' )        // true
console.log( false == NaN )       // false

综上:js的false值只有 false ,0 ,''

ps:欢迎补充

ps:补充:感谢楼下那位博主,false值还有空数组[],[0],

原文地址:https://www.cnblogs.com/lwwen/p/5806085.html