<html><title>js变量类型详解
</title><meta http-equiv="content-type" content="text/html; charset=utf-8" /> <body><div class="img">js变量类型详解</div></body><script>//字符串类型str="简化";document.write("我是字符串变量:"+str+"<br/>");//整型aa=100;document.write("我是整型变量:"+aa+"<br/>");//浮点fo=100.1;document.write("我是浮点型变量:"+(fo+2)+"<br/>");//布尔型score =false;if(score){document.write("我是布尔型变量:Y<br/>");}else{document.write("我是布尔型变量:N<br/>");}//数组arr=new Array(‘01‘,‘02‘,‘03‘,‘04‘);document.write("输出整个数组"+arr+"<br/>");document.write("数组指定下标"+arr[2]+"<br/>");//对象document.write("----js对象----<br/>");obj=new Object();//生成对象obj.username="jie";//定义对象的属性和方法obj.age=15;obj.sex="男";obj.say=function(){document.write("执行了jie对象说话的方法<br/>");}document.write("jie对象的名字是"+obj.username+"<br/>");//调用对象的变量document.write("jie对象的年龄是"+obj.age+"<br/>");//调用对象的变量obj.say();//调用对象的方法document.write("----dom对象----<br/>");//document对象//json对象document.write("----json对象----<br/>");jsobj={‘username‘:‘jie‘,‘age‘:‘18‘,‘sex‘:‘男‘,‘say‘:function(){//this代表本对象document.write("调用json内部的属性:"+this.username+"<br/>")}};document.write(jsobj.sex+"<br/>");jsobj.say();//NaN类型//null类型srt02=null;document.write(srt02);//undefined类型</script></html>
js变量类型详解
原文地址:http://www.cnblogs.com/soulsjie/p/7634572.html