函数作用域

<!DOCTYPE html>
<html>
<head>
<title> test</title>

<script type="text/javascript">

var v1 = 'global';

var f1 = function(){

alert(v1);

}


f1();


var f2 = function(){

var v1 = 'local';

f1();


};


f2();

</script>
</head>
<header>
<h1>Welcome to my homepage</h1>
<p>My name is Donald Duck</p>
</header>
<body>
<input type="button" onclick="aaa()" />
<div width="100" style="background-color:white;">test</div>
</body>

</html>

posted @ 2014-11-09 13:06  zaizai2013  阅读(119)  评论(0编辑  收藏  举报