JavaScript中基础变量和数据类型的定义

来源:互联网 发布:最流行的网络语言 编辑:程序博客网 时间:2024/05/21 14:52
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><body><script type="text/javascript">var i=10;var j=10;var m=i+j;document.write(m);//output:20</script><script type="text/javascript">var string="hello";//定义字符串类型var i=10;//定义数字类型var flag=true;//定义bool类型var arr=[1,2,3,4];//定义int类型的数组var arr2=["hehe","xixi","haha","huhu"];//定义String类型的数组var arr3=new Array("hehe","xixi","haha","huhu");//第二种定义字符串数组document.write(arr3[2]);//output:haha</script><script type="text/javascript">var arr=new Array();arr[0]=10;arr[1]=20;arr[2]=30;document.write(arr[2]);//output:30</script><script type="text/javascript">  var m=11;document.write(m);//11var isnull=null;m=null;//重置m变量为nulldocument.write(isnull);//nulldocument.write(m);//null</script></body></html>

0 0
原创粉丝点击