如何检查 JavaScript 中未定义的变量?

javascriptweb developmentfront end technology

要检查变量是否"undefined(未定义)",您需要使用以下方法检查。如果结果为"false",则表示变量未定义。此处,变量结果为"True"减号

示例

<html>
   <body>
      <script>
         var points = 100;
            if(points){
               document.write("True");
            }else{
               document.write("False");
            }
      </script>
   </body>
</html>

相关文章