SOURCE

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()
console 命令行工具 X clear

                    
>
console