【发布时间】:2018-12-08 07:10:24
【问题描述】:
我尝试使用原型链接将函数y() 添加到对象构造函数x 中。它导致unexpected 错误:
意外令牌
{
function x(a, b) {
this.a = a
this.b = b
}
x.prototype.y(){
console.log('hello')
}
我希望函数 x 为:
function x(a, b) {
this.a = a;
this.b = b;
y()
}
【问题讨论】:
标签: javascript object prototype object-construction function-constructor