<!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);//11 var isnull=null; m=null;//重置m变量为null document.write(isnull);//null document.write(m);//null </script> </body> </html>
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-13 20:00:48