<p>局部变量在声明的函数内可以访问。</p> <p id="demo"></p> <script> myFunction(); document.getElementById("demo").innerHTML = "我可以显示 " + typeof carName; function myFunction() { var carName = "Volvo"; } </script>