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-01-07 11:16  盖世神功  阅读(946)  评论(0编辑  收藏  举报