您的位置:首页 > Web前端 > JavaScript

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

2015-09-06 16:36 501 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: