<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript"> var a = 123;
function fun(){
alert(a);//undefined
var a = 456;
alert(a);//456
}
fun();
alert(a);//123 //--------------------------------------------------- var b = 123;
function fun(){
alert("b = "+b);//123
b = 456;
}
fun();
alert("b = "+b);//456,全局的b变成了456 //--------------------------------------------------- var c = 123;
function fun(c){
alert("c = "+c);//undefined
c = 456;//对外面的c没影响
}
fun();
alert("c = "+c);//123 //--------------------------------------------------- var d = 123;
function fun(d){
alert("d1 = "+d);//789
d = 456;
}
fun(789);
alert("d = "+d);//123 </script>
</head>
<body>
</body>
</html>