javascript 基礎1第11節

來源:互聯網
上載者:User

標籤:

<html><head><title>javascript基礎</title></head><body>1.NaN  isNaN()</br><script type="text/javascript">  //資料類型轉換失敗 返回NaN類型  document.write("parseInt(‘a‘) : " ,parseInt(‘a‘),"<br/>");  document.write("parseInt(‘9‘) : " ,parseInt(‘9‘),"<br/>");  document.write("NaN == NaN : " , NaN == NaN,"<br/>");</script>     2.關係運算子  >  >=  < <=  !=  ==  ===</br><script type="text/javascript">  document.write("‘7‘ < 5  : " ,‘7‘ < 5,"<br/>");//發生類型轉換  document.write("‘7‘ > 5  : " ,‘7‘ > 5,"<br/>");  document.write("‘7‘ > ‘12‘  : " ,‘7‘ > ‘12‘,"<br/>");//不發生類型轉換  document.write("‘a‘ > 12  : " ,‘a‘ > 12,"<br/>");//發生類型轉換  document.write("‘a‘ < 12  : " ,‘a‘ < 12,"<br/>");//發生類型轉換  document.write("isNaN(‘a‘)  : " ,isNaN(‘a‘) ,"<br/>");//是否是非數字  document.write("isNaN(‘8‘)  : " ,isNaN(‘8‘) ,"<br/>");  document.write("100 == ‘100‘   : " , 100 == ‘100‘ ,"<br/>");  document.write("100 === ‘100‘   : " , 100 === ‘100‘ ,"<br/>");//值相等  類型相同  document.write("‘100‘ === ‘100‘   : " , ‘100‘ === ‘100‘ ,"<br/>");</script>     3.賦值運算子  =  += -= *= /=   %=</br>4.邏輯運算子  !&& ||</br><script type="text/javascript"> //任何類型使用!結果是布爾型  true  --- null ‘‘ 0  undefined document.write("!true   : " , !true ,"<br/>"); document.write("!5   : " , !5 ,"<br/>"); document.write("!0   : " , !0 ,"<br/>"); document.write("!-2   : " , !-2 ,"<br/>"); document.write("!null   : " , !null ,"<br/>"); document.write("!new Date()   : " , !new Date() ,"<br/>");</script>     5.類型轉換</br><script type="text/javascript">document.write("parseInt(‘123‘) : " ,parseInt(‘123‘),"<br/>");document.write("parseInt(‘123a‘) : " ,parseInt(‘123a‘),"<br/>");document.write("parseInt(‘a123‘) : " ,parseInt(‘a123‘),"<br/>");document.write("parseInt(‘123.456‘) : " ,parseInt(‘123.456‘),"<br/>");document.write("parseFloat(‘123.456‘) : " ,parseFloat(‘123.456‘),"<br/>");document.write("parseFloat(‘123.456.789‘) : " ,parseFloat(‘123.456.789‘),"<br/>");document.write("parseFloat(‘123.a.789‘) : " ,parseFloat(‘123.a.789‘),"<br/>");document.write("parseFloat(‘a123.789‘) : " ,parseFloat(‘a123.789‘),"<br/>");var a = 20;var b = 50;document.write("a + b = " ,a + b,"<br/>");document.write("a.toString() + b = " ,a.toString() + b,"<br/>");document.write("‘10‘ + b = " ,‘10‘ + b,"<br/>");//字串 串連document.write("‘10‘ - b = " ,‘10‘ - b,"<br/>");//類型轉換 進行計算document.write("‘a‘ - b = " ,‘a‘ - b,"<br/>");</script>     </body></html>

 結果:

2.

javascript 基礎1第11節

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.