zoukankan      html  css  js  c++  java
  • js变量类型详解

    <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>
    
  • 相关阅读:
    PHP实现html字符实体转汉字
    利用 secureCRT 直接上传下载文件 (sz,rz)
    CentOS安装scp命令
    以Apache模块的方式编译安装php-5.5.4
    编译安装 apache 2.4.6
    协方差Covariance的表述推导
    Java _ JDK _ Arrays, LinkedList, ArrayList, Vector 及Stack
    Java_一些特殊的关键字详(?)解
    Java_你应该知道的26种设计模式
    排序与搜索一览
  • 原文地址:https://www.cnblogs.com/soulsjie/p/7634572.html
Copyright © 2011-2022 走看看