javascript当中嵌套函数

3)嵌套函数
例 3.3.1
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<script>
    function outerFun(){
        var i = 0;
        function innerFun(){
            document.write(i);
        }
        innerFun();
    }
    outerFun();
    /*here you can not call innerFun(), because it is inside another function outerFun, so it will cause error.*/
    innerFun();
    document.write("马克-to-win");
</script>

更多内容请见原文,文章转载自:https://blog.csdn.net/qq_44594249/article/details/99978852

posted @ 2020-12-26 19:49  师徒行者  阅读(251)  评论(0编辑  收藏  举报