参考文章
构造函数时,若是作为对象的的私有方法则采用如下方式
function f1(){
this.fn1 = function(){
...
}
this.fn2 = function(){
...
}
}
若是作为不同对象的公共函数则采用
function f1(){
}
f1.prototype.fn1 = function(){
...
}
f2.prototype.fn2 = function(){
...
}
参考文章
构造函数时,若是作为对象的的私有方法则采用如下方式
function f1(){
this.fn1 = function(){
...
}
this.fn2 = function(){
...
}
}
若是作为不同对象的公共函数则采用
function f1(){
}
f1.prototype.fn1 = function(){
...
}
f2.prototype.fn2 = function(){
...
}