不好意思 自己想出来了~ 打搅大家来~~
<script>
function a(){
this.b=function(){
alert(this.b.caller)
}
}
var c=new a()
c.b()
</script>
少了个this

解决方案 »

  1.   

    还有一点疑问  为什么上面的式子返回null呢? 难道不应该是a(){………}吗?
    注:
    caller返回一个对函数的引用,该函数调用了当前函数。
    functionName.caller 
    functionName 对象是所执行函数的名称。
    说明
    对于函数来说,caller 属性只有在函数执行时才有定义。如果函数是由顶层调用的,那么 caller 包含的就是 null 。如果在字符串上下文中使用 caller 属性,那么结果和 functionName.toString 一样,也就是说,显示的是函数的反编译文本。
      

  2.   

    发个显示正确的例子吧
    <script>
    function callerDemo() {
        if (callerDemo.caller) {
            var a= callerDemo.caller.toString();
            alert(a);
        } else {
            alert("this is a top function");
        }
    }
    function handleCaller() {
        callerDemo();
    }
    handleCaller()
    </script>
    显示
    ---------------------------
    function handleCaller() {    callerDemo();}
    ---------------------------
      

  3.   

    找到原因了 
    对于函数来说,caller 属性只有在函数执行时才有定义
    感觉类似于 var了的变量
    function a(){
    this.b=function(){
    alert(this.b.caller)
    }
    this.b()
    }

    new a()function a(){
    this.b=function(){
    alert(this.b.caller)
    }
    this.b()
    }

    new a()
    function a(){
    b=function(){
    alert(b.caller)
    }
    b()
    }
    a()
    this去掉和不去都是一样的  还有多种变化