前一段时间看了本书,做个总结:
lIn the JavaScript, implement closure through function (variable from function body) definein the function body.
例子如下:
<html>
<body>
<script type="text/javascript">
function a(){
var i=0;
function b(){
alert("Hello World!"+(++i));
}
return b;
}
var c=a();
c();
c();
</script>
</body>
</html>
lIn the JavaScript, implement closure through function (variable from function body) definein the function body.
例子如下:
<html>
<body>
<script type="text/javascript">
function a(){
var i=0;
function b(){
alert("Hello World!"+(++i));
}
return b;
}
var c=a();
c();
c();
</script>
</body>
</html>