js的call-继承

function fun1() {

 

this.add = function () { return this.a }

}

function fun2() {

 

this.sub = function () { return this.a-this.b }

}

function fun3() {

this.a = 10;

this.b = 2;

fun1.call(this);

fun2.call(this);

}

var f3 = new fun3()

alert(f3.add());

alert(f3.sub());

posted @ 2015-08-09 16:36  wjl910  阅读(27)  评论(0)    收藏  举报