<script>
function test(){
    testd = "Hello";
}
test();
alert(testd);
</script>

当未定义的时候  “tsestd”这个未声明的变量自动成为全局变量声明

<script>
function test(){
    var testd = "Hello";
}
test();
alert(testd);
</script>

当在函数内部声明了该变量 此时 “testd is not defined”。

 

相关文章:

  • 2022-12-23
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-11-18
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案