在网页脚本,js引擎是按从上到下解释的,所以变量和函数都必须在 使用前声明!但在同一个<script></script>内,函数可以先使用再声明,变量不行。例如:
<script type="text/javascript">
he();
function he()
{
alert("hello world");
}
</script>
这样可以运行!
<script type="text/javascript">
he();
function he()
{
alert(a);
}
var a="hello world";
</script>
会出现错误!