• 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>
    
  • 相关阅读:
    自定义ASP.NET MVC Html标签辅助方法
    解决github.com无法访问
    Func<>用法
    Entity Framework 在OrderBy排序中使用字符串
    <input type="file"> 标签详解
    JS实现上传图片的三种方法并实现预览图片功能
    一个关于双目运算符的测试
    堆和栈的区别
    C# 代码笔记_tuple元组
    小程序前后端自定义登录与一键登录兼容demo分享
  • 原文地址:https://www.cnblogs.com/soulsjie/p/7634572.html
Copyright © 2020-2023  润新知