我的下面代码有什么问题?我得到错误对象#没有方法'减去'。
function result() {
}
result.prototype.add = function (a,b) {
var sub = this.subtract(a,b);
}
result.prototype.subtract = function (a,b) {
return a-b;
}
module.exports = result;
答案 0 :(得分:0)
快速猜测是调用new
函数。
function result() {
}
result.prototype.add = function (a,b) {
var sub = this.subtract(a,b);
}
result.prototype.subtract = function (a,b) {
return a-b;
}
module.exports = new result();