日期:2014-05-16 浏览次数:20438 次
function base() {
this.member = "global";
this.method = function() {
console.log("global method");
return "global method return";
};
}
(function extend() {
base.call(this);
console.log(this.member);
console.log(this.method());
})();
global global method global method return
global method global global method return
<script type="text/javascript">
function base() {
this.member = "global";
this.method = function() {
console.log("global method");
return "global method return";
};
}
(function extend() {
base.call(this);
console.log(this.member); //这句输出global ,因为base函数的this.member 就是 "global";
console.log(this.method()); //这句输出 global method global method return //lz你可以把这句注释掉就清楚了,
})();
</script>