闭包 进阶 javascript
源码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery.min.js" language="javascript" type="text/javascript">
</script>
<script src="wkl_ajax.js" language="javascript" type="text/javascript">
</script>
<script type="text/javascript">
function f1(){
var n=999;
var ni = {
hao: function()
{
alert("890");
}
}
nAdd=function(){n+=1}
function f2(){
var hello = 10;
return me;
// alert(n);
}
function me(){
return ni;
}
return f2;
}
var me = new f1();
me()().hao(); //890
</script>
</head>
<body>
<div class="me">test</div>
</body>
</html>
完