call

//        ##FE通过call apply 借调其他函数FF
//           * 当FF为构造函数的时候,FE继承了FF的实例属性以及实例方法
//           * 当FF为普通函数的时候,FE调用它,但FF的context变成了FE

        var A = function () {
            console.log('executing A');
            this.name = "I\'am A";
            this.sayName = function () {
                console.log('hello, ' + this.name);
            }
        };
        A.prototype.protoMethod1 = function () {
            console.log("this is A' prototype method");
        };

        A.staticMethod1 = function () {
            console.log('this is A\' static method');
        }


        var B = function () {
            A.call(this);
        };

典型应用

Array.prototype.slice.call(this, [start], [end])

[].slice.call(this, [start], [end])

posted @ 2012-10-29 11:50  leamiko  阅读(154)  评论(0编辑  收藏  举报
document.getElementById('MySignature') && document.getElementById('MySignature').style.display = "none"; document.getElementById('MySignature') && document.getElementById('blog_post_info').style.display = "none";