zoukankan      html  css  js  c++  java
  • 其他数据类型转布尔类型

    方法:Boolean(变量)

    注意:

    数字(非零)和字符串转完之后为true

            var n1=Infinity;
            var n2="345";
            var n3="前端";
            console.log(Boolean(n1));//true
            console.log(Boolean(n2));//true
            console.log(Boolean(n3));//true

    undefinednull0,空字符串转完之后为false.

            var n4;
            console.log(Boolean(n4));//false
            var n5=null;
            console.log(Boolean(n5));//false
            var n6=0;
            console.log(Boolean(n6));//false
            var n7="";
            console.log(Boolean(n7));//false
  • 相关阅读:
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    C++生产和使用的临时对象
    RecyclerView0基于使用
    Docker创建MySQL集装箱
  • 原文地址:https://www.cnblogs.com/EricZLin/p/8597372.html
Copyright © 2011-2022 走看看