代码
提交代码
function Calculate (x, y) { this.x = x this.y = y } Calculate.prototype.add = function () { return this.x + this.y } var calculate = new Calculate(1, 2) console.log(calculate.add()) // 3
运行结果