<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=GB2312"/>
<title> 4.2 函数和变量作用域 </title>
<!--脚本部分-->
<script type="text/javascript">
var v1,v2;
v1=10;
v2=20;
function a(){
var v2,v3;
alert("v1="+v1+"
v2= "+v2+"
v3="+v3);
v2=v3=40;
function b(v3,v4){
alert("v3 = "+v3+"
v4="+v4);
v2=v3=80;
}
b(v3);
alert("v2="+v2+"
v3="+v3);
alert(v4);
}
a();
</script>
</head>
<body style="overflow:auto;">
</body>
</html>
函数外的变量在函数里面无需声明直接使用,函数里面声明的变量在函数外部是无效的.