【发布时间】:2012-10-09 09:34:02
【问题描述】:
function condition(){
this.expression = "";
this.toString = function(){
return this.expression;
}
};
function and(first, second){
this.expression = first + " and " + second;
}
function nop(){};
nop.prototype = condition.prototype;
and.prototype = new nop();
var a =new and(1,2);
console.log(a.toString());
预计会看到“1 和 2”作为输出,但实际情况如下: “[对象对象]”
【问题讨论】:
标签: javascript oop inheritance