条件语句补充
switch
switch (i) {
case 4:
document.write('a')
i++
case 5:
document.write('b')
i++
case 6:
document.write('c')
i = 0;
case null:
document.write('null')
}
break
for(k = 0; k < 10; k ++){
if (k != 8) {
document.write('k')
}else{
break;
}
}
switch (i) {
case 1:
document.write('a')
i++
break;
case 2:
document.write('b')
i++
case 3:
document.write('c')
var i = 6;
default:
break;
}
continue
中止本次循环,进行下次循环
面向对象
var obj = {
name = 'asd',
sex = 'boy'
}
typeof
document.write(typeof(k));//写法1
document.write(typeof k);//写法2
类型转换
显性类型转换
Number
数字类型
parseInt
var demoo = "10";
var num = parseInt(demo,16);
//转换进制
var num = parseInt(demo);
//转换整型
string
字符串
tostring也可以转换进制
var num = demo.tostring();
隐性类型转换
isNaN →Number();
++/-- +/-
+
-*/% →Number
&&||!
< > <= >=
== !=