代碼
提交代碼
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
運(yùn)行結(jié)果