2.5.Javascript--布尔型
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
var boolA = true;
var boolB = false;
var boolC = new Boolean(true);
var boolD = new Boolean(false);
document.write( boolA == boolC );
document.write("</br>");
document.write( boolB == boolD );
document.write("</br>");
if( boolA.constructor == Boolean ){
document.write("布尔型");
}
//注释:如果省略 value 参数,或者设置为 0、-0、null、""、false、undefined 或 NaN,则该对象设置为 false。否则设置为 true(即使 value 参数是字符串 "false")。
var bool1 = new Boolean(0);
var bool2 = new Boolean(-0);
var bool3 = new Boolean(null);
var bool4 = new Boolean("");
var bool5 = new Boolean(false);
var bool6 = new Boolean(undefined);
var bool7 = new Boolean(NaN);
document.write( bool1 + "<br/>");
document.write( bool2 + "<br/>");
document.write( bool3 + "<br/>");
document.write( bool4 + "<br/>");
document.write( bool5 + "<br/>");
document.write( bool6 + "<br/>");
document.write( bool7 + "<br/>");
</script>
</body>
</html>