Function.prototype.addMethod = function(name, fn) {
this[name] = this.prototype[name] = fn
return this
}
var Methods = function () {}
var m = new Methods()
Methods.addMethod('sayHello', function () {
console.log('hello')
return this
}).addMethod('sayName', function () {
console.log('xiaoming')
return this
})
m.sayHello().sayName()
Methods.sayHello().sayName()