高级程序设计里面的写法是下面这样的function Person(name,age,job){ this.name = name; this.age = age; this.job = job; this.lessons = ['Math','Physics'];
}
Person.prototype = { constructor: Person,
getName: function(){ return this.name;
}
}那么我像下面这样写是不是一样的,区别只在于他们的constructor不一样?function Person(name,age,job){ this.name = name; this.age = age; this.job = job; this.lessons = ['Math','Physics'];
Person.prototype.getName = function(){ return this.name;
}
}
添加回答
举报
0/150
提交
取消