久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript怎么將數(shù)據(jù)轉(zhuǎn)為布爾值

      javascript將數(shù)據(jù)轉(zhuǎn)為布爾值的方法:1、使用雙重邏輯非,語(yǔ)法“!!需要轉(zhuǎn)換的值”;2、使用Boolean()函數(shù),語(yǔ)法“Boolean(需要轉(zhuǎn)換的值)”。

      javascript怎么將數(shù)據(jù)轉(zhuǎn)為布爾值

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

      把值轉(zhuǎn)換為布爾值的常用方法有 2 種,具體說(shuō)明如下。

      1. 使用雙重邏輯非

      一個(gè)邏輯非運(yùn)算符!可以把值轉(zhuǎn)換為布爾值并取反,兩個(gè)邏輯非運(yùn)算符就可以把值轉(zhuǎn)換為正確的布爾值。

      console.log(!!0);  //返回false console.log(!!1);  //返回true console.log(!!"");  //返回false console.log(!!NaN);  //返回false console.log(!!null);  //返回false console.log(!!undefined);  //返回false console.log(!![]);  //返回true console.log(!!{});  //返回true console.log(!!function(){});  //返回true

      2. 使用 Boolean() 函數(shù)

      使用 Boolean() 函數(shù)可以強(qiáng)制把值轉(zhuǎn)換為布爾值。

      console.log(Boolean(0));  //返回false console.log(Boolean(1));  //返回true

      【推薦學(xué)習(xí):javascript高級(jí)教程】

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)