JavaScript中什么是复杂数据类型?
JavaScript中的复杂数据类型包括typeof运算符。该 typeof运算 操作是一元运算符是其单个操作数之前放置,其可以是任何类型的。它的值是一个字符串,指示操作数的数据类型。
如果typeof运算符的操作数是数字,字符串或布尔值,则其计算结果为“数字”,“字符串”或“布尔值”,并根据计算结果返回true或false。
示例
您可以尝试运行以下代码,以了解如何在JavaScript中使用typeof运算符-
<html>
<body>
<script>
<!--
var a = 10;
var b = "String";
var linebreak = "<br />";
result = (typeof b == "string" ? "B is String" : "B is Numeric");
document.write("Result => ");
document.write(result);
document.write(linebreak);
result = (typeof a == "string" ? "A is String" : "A is Numeric");
document.write("Result => ");
document.write(result);
document.write(linebreak);
//-->
</script>
</body>
</html>热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短