<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JS基础</title> <script type="text/javascript"> var a,b,sum; var a = 5; var b = 100%7; sum = a > b ; document.write( "我认为 a 的值是:" + a + " b的值是:" + b + "sum 的值是:" +sum+"<br/>"); sum = ( (++a) + 3 ) / (2 - (--b) ) * 3; document.write("sum的值是:"+27); document.write("答案是:"+sum+"<br/>"); /*var array=new Array(10); array=[1,2,3,4,5,6,7,8,9,10,11];*/ var array=[1,2,3,4,5]; document.write("数组的长度为"+array.length+"<br>"); for(i=0;i<5;i++) { document.write((array[i])+"<br/>"); } var myarr=new Array(); for(var i=0;i<3;i++) { myarr[i]=new Array(); for(var n=0;n<6;n++) { myarr[i][n]=i*n; } } document.write(myarr); var arr=['*','**','***']; alert("该数组的长度为:"+arr.length); for(var j=0;j<3;j++); { document.write(arr[j]); } var myweek=3; switch(myweek) { case 1: case 2: document.write("学习理念知识"); break; case 3: case 4: document.write("到企业实践"); break; case 5: document.write("总结经验"); break; case 6: case 7: document.write("周六、日休息和娱乐"); default; } </script> </head> </html>
可是我运行的时候var arr=['*','**','***'];这个数组显示出来的结果是undefined,我明明给它赋值了。
default:;