判断方法就是使用typeof方法直接判断变量的类型是否为"undefined"
<!DOCTYPE html>
<html>
<script>
var a;
if(typeof(a)=="undefined"){
alert("yes");
}else{
alert("no");
}
</script>
</html>
typeof方法的返回值有:boolean、function、number、object、string、undefined
判断方法就是使用typeof方法直接判断变量的类型是否为"undefined"
<!DOCTYPE html>
<html>
<script>
var a;
if(typeof(a)=="undefined"){
alert("yes");
}else{
alert("no");
}
</script>
</html>