js中常见数据类型输出情况

来源:互联网 发布:云存储软件 编辑:程序博客网 时间:2024/05/29 01:56

js中常见数据类型分析:

<!–

3 alert("typeof(1):" + typeof(1));//number
4 alert("typeof(\"abc\"):" + typeof("abc"));//string
5 alert("typeof(true):" +typeof(true));//boolean
6 alert("typeof(2009-2-4):" + typeof(2009-2-4));//number
7 alert("typeof(\"2009-2-4\"):" + typeof("2009-2-4"));//string
8 alert("typeof(m):" + typeof(m));//undefined,字符串连上一个,m是个未定义的变量undefined。
9 var d=new Date();
10 alert("typeof(d):" + typeof(d));//object
11 function Person(){};
12 alert("typeof(Person):" + typeof(Person));//function
13 var a=new Array();
14 alert("typeof(a):" + typeof(a));//object
15 alert("a instanceof Array:" + (a instanceof Array));
16 var h=new Person();
17 var o={};
18 alert("h instanceof Person:" + (h instanceof Person));//true
19 alert("h instanceof Object:" + (h instanceof Object));//true
20 alert("o instanceof Object:" + (o instanceof Object));//true
21 alert(typeof(h));//object
0 0
原创粉丝点击