zoukankan      html  css  js  c++  java
  • JavaScript Boolean Object 逻辑

    Create a Boolean Object

    The Boolean object represents two values: "true" or "false".

    The following code creates a Boolean object called myBoolean:

    var myBoolean=new Boolean();

    If the Boolean object has no initial value, or if the passed value is one of the following:

    • 0
    • -0
    • null
    • ""
    • false
    • undefined
    • NaN

    the object is set to false. For any other value it is set to true (even with the string "false")!

    实例:

    <!DOCTYPE html>
    <html>
    <body>
    
    <script>
    var b1=new Boolean(0);
    var b2=new Boolean(1);
    var b3=new Boolean("");
    var b4=new Boolean(null);
    var b5=new Boolean(NaN);
    var b6=new Boolean("false");
    
    document.write("0 is boolean "+ b1 +"<br>");
    document.write("1 is boolean "+ b2 +"<br>");
    document.write("An empty string is boolean "+ b3 + "<br>");
    document.write("null is boolean "+ b4+ "<br>");
    document.write("NaN is boolean "+ b5 +"<br>");
    document.write("The string 'false' is boolean "+ b6 +"<br>");
    </script>
    
    </body>
    </html>
  • 相关阅读:
    [hdu4035]maze
    [codeforce][148d]
    [bzoj3507]通配符匹配
    [BZOJ4831]
    子串
    【洛谷1373】小a和uim之大逃离
    【JZOJ6303】演员
    [jzoj6296]选票
    字符串哈希
    [ABC137d&e]RE
  • 原文地址:https://www.cnblogs.com/amosli/p/3475418.html
Copyright © 2011-2022 走看看