【读jQuery源码有感系列一】callee

<script type="text/javascript">

        /*调用自身*/
        function calleeDemo() {
            try{
                
            }
            catch (error){
              setTimeout(arguments.callee,0);

            }
            alert(arguments.callee);
        }calleeDemo();

        /**是谁掉用了我*/
        function callerDemo() {
            if (callerDemo.caller) {
                var a= callerDemo.caller.toString();
            } else{
                alert("this is a top function");
            }
        }
        callerDemo();
        function handleCaller() {
            callerDemo();
        }
        handleCaller();
    </script>

 

你可能感兴趣的:(jquery)