先对js的几个特殊属性与函数做点解释:
caller:每个函数(方法)都有的属性,可知是由谁调用此方法。
call: 每个函数都有的方法,可调用父构造函数(调用一个对象的一个方法,以另一个对象替换当前对象(其实就是更改对象的内部指针,即改变对象的this指向的内容))。
prototype:js对象均有的一个属性,也称原型属性

<html>
<head>
<script type="text/javascript">
    /**
    动物,父类
    */
    function Animal(name)
    {
        this.name = name;
        this.sleep = function ()
        {
            alert("name is :" + this.name +" ,\r\n it's a sleep function 。\r\n the caller is:" + this.sleep.caller);
        }
     }
     /**
         子类,老虎
    */
    function Tiger() </body>
</html>


相关文章: