<!DOCTYPE>
<html>
<head>
<title> New Document </title>
</head>
<body>
<script>
function foo(){var a=2;bar()};
function bar(){console.log(a)};
foo()
</script>
</body>
</html>
js这段代码会报 这个错误 Uncaught ReferenceError: a is not defined, 解决方法到是有很多,但是不明白为什么会报错; 请各位达人们,给出一个比较透彻的解释