判断方法就是使用typeof方法直接判断变量的类型是否为”undefined”

 1<!DOCTYPE html>
 2<html>
 3    <script>
 4        var a;
 5        if(typeof(a)=="undefined"){
 6            alert("yes");
 7        }else{
 8            alert("no");
 9        }
10    </script>
11</html>
个人笔记记录 2021 ~ 2025