Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
console.log(typeof 100);
console.log(typeof 'aaaa');
console.log(typeof true, typeof false);
let a; //undefined 是变量的默认值
console.log(a);
console.log(typeof null);
const arr =['电脑', 2, 5000];
console.table(arr);
console.log(arr[0]);
console.log(arr[1]);
console.log(arr[2]);
console.log(arr,length);
console.log(typeof arr);
console.log(Array.isArray(arr));
let obj ={
name: '电脑',
num:2,
price:5000,
'my email': '123@qq.com',
};
console.log(obj['name']);
console.log(obj.name);
console.log(obj['my email']);
函数,函数既是数据类型,也是对象。
最在的优点就是可以当成函数的参数进行回调。
age = 121;
if(age >= 18 && age <35){
console.log('允许观看');
}
//这一块就是单分支
else if(age >= 35 && age < 60){
console.log('允许多人观看');
}
//双分支
else if(age >= 60 && age < 120){
console.log('建议陪同观看');
}
//多分支
else if(age >= 120 || age < 8){
console.log('非法年龄');
}
//默认
else {
console.log('少儿不易');
}
const colors = ['red', 'green', 'blue'];
let i = 0;
let length = colors.length;
if(i < length){
console.log(colors[i]);
//i = i + 1;
i++;
}
if(i < length){
console.log(colors[i]);
i = i + 1;
}
if(i < length){
console.log(colors[i]);
i = i + 1;
}else {
console.log('遍历结束');
}