批改状态:合格
老师批语:
// *数据类型// *1原始类型// *number类型let a=100;console.log(typeof a);// *string类型let b='welcome php';console.log(typeof b);// *boolean类型let c=true;console.log(typeof c);// *null类型let d=null;console.log(typeof d);// *undefined类型let e;console.log(typeof e);// *2.引用类型// *a数组类型const man=['张三',25,'男'];console.log(man);console.log(Array.isArray(man));// *对象类型const obj={name:'张三',age:21,sex:'男',};console.log(obj);console.log(typeof obj);// *函数类型function a1(){return 'welcome php';}console.log(a1());console.log(typeof a1);

// *单分支let height=1.2;if(height>=1.2){console.log('凭票进场');}// *双分支height=1;if(height>=1.2){console.log('凭票进场');}else{console.log('免票进场');}// *三元操作height=1.5let a2=height>=1.2?'凭票进场':'免票进场';console.log(a2);// *switchlet age=70;switch(true){case age >=1 && age<7:console.log('免票进场');break;case age>=7 &&age<12:console.log('半票进场');break;case age>=12 && age<60:console.log('全票进场');break;case age>=60 && age<70:console.log('凭身份证半票进场,如无全票进场');break;case age>=70 && age<120:console.log('凭身份证免票进场,如无全票进场');break;case (age>0 && age<1) || age>=120:console.log('不适合的年龄段,不能进场');break;default:console.log('错误数据');break;}// *1while循环// *常量型数组const sanguo=['魏国','蜀国','吴国'];let i=0;while(i<sanguo.length){console.log(sanguo[i]);i++;}// *2do-while循环i=0;do{console.log(sanguo[i]);i++;}while(i<sanguo.length);// *3for循环for(i=0;i<sanguo.length;i++){console.log(sanguo[i]);}// *4for-of循环for(let item of sanguo){console.log(item);}// *5for-in循环// *用常量型来表示一个微信群对象const weixinqun={obj1:'刘备',obj2:'关羽',obj3:'张飞',obj4:'孔明',obj5:'赵云',};// *用for-in循环来遍历对象:for(let key in weixinqun){console.log(weixinqun[key]);}



Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号