【发布时间】:2012-05-17 00:46:36
【问题描述】:
这是代码吗,
function Person() {
function myMethod() {
alert ('hello');
}
this.method = myMethod;
}
相当于:
function Person() { }
Person.prototype.method2 = function() {
alert ('hello');
};
如果是,我应该使用哪种方法定义以及为什么?
【问题讨论】:
标签: javascript oop methods prototype