JavaScript 類型轉(zhuǎn)換
JavaScript?型別轉(zhuǎn)換
Number() 轉(zhuǎn)換為數(shù)字, String() 轉(zhuǎn)換為字串, Boolean() 轉(zhuǎn)換為布林值。
JavaScript 資料類型
在JavaScript 中有5 種不同的資料類型:
string
number
boolean
#object
function
3 種物件型別:
Object
Date
Array
##2個不包含任何值的資料型態(tài):nullundefinedtypeof 運算子你可以使用?typeof?運算子來檢視JavaScript 變數(shù)的數(shù)據(jù)類型。<html> <body> <script type="text/javascript"> var test=new Array(); if (test.constructor==Array) { document.write("This is an Array"); } if (test.constructor==Boolean) { document.write("This is a Boolean"); } if (test.constructor==Date) { document.write("This is a Date"); } if (test.constructor==String) { document.write("This is a String"); } </script> </body> </html>