亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JavaScript 類型轉(zhuǎn)換

JavaScript?類型轉(zhuǎn)換

Number() 轉(zhuǎn)換為數(shù)字, String() 轉(zhuǎn)換為字符串, Boolean() 轉(zhuǎn)化為布爾值。

JavaScript 數(shù)據(jù)類型

在 JavaScript 中有 5 種不同的數(shù)據(jù)類型:

string

number

boolean

object

function

3 種對象類型:

Object

Date

Array

2 個(gè)不包含任何值的數(shù)據(jù)類型:

null

undefined

typeof 操作符

你可以使用?typeof?操作符來查看 JavaScript 變量的數(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>
繼續(xù)學(xué)習(xí)
||
<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>
提交重置代碼