标签:span class 自动 转换 控制 条件 else htm pretty
<!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><script type="text/javascript">/*if判断语句格式:if(判断条件){符合条件的代码;}else{不符合条件的代码;}if语句特殊之处:在javascript中的if语句条件不但可以写布尔表达式,还可以写任何的数据。判断的条件会发生自动类型转换number:如果非0为true,0为falsestring:如果非null或非空为true,否则为falseundefined:falseNaN: false对象类型:非null为true,否则为false。*/var age = 19;if(age >= 18){document.write("成年");}else{document.write("未成年");}document.write("<br/>");//if语句特殊之处var condition = NaN;condition = "";condition = null;condition = 9;condition = 0;condition = -22;condition;if(condition){document.write("满足条件");}else{document.write("不满足条件");}</script></head><body></body></html>
标签:span class 自动 转换 控制 条件 else htm pretty
原文地址:http://www.cnblogs.com/itMiracle/p/5990745.html