javascript中常见的数据类型有String,Number,Boolean,初次之外还有Object,Undefined,Function,
例如以下代码:
- <script type="text/javascript">
- function testTypeOf() {
- var message = "hello";
- alert(typeof(message)); //string
- var num = 110;
- alert(typeof(num)); //number
- var boo = false;
- alert(typeof(boo)); //boolean
- var unde;
- alert(typeof(unde)); //undefined
- var fun = function(){return;};
- alert(typeof(fun)); //function
- var nul = null;
- alert(typeof(nul)); //object
- alert(typeof 9);
- }
- testTypeOf();
- </script>
本文介绍了JavaScript中的基本数据类型,包括String、Number、Boolean等,并通过示例代码展示了如何使用typeof操作符来判断变量的数据类型。
1440

被折叠的 条评论
为什么被折叠?



