Function.prototype.addMethod = function (name, fn,proto) {


// console.log(proto)


if (proto===true){


this[name] = fn;


}else{


this.prototype[name] = fn;


}


 


return this;


}


var methods = function () { };


// console.log(Methods.addMethod)


methods.addMethod('chek1', function () {


console.log('chek1')


return this;


}).addMethod('chek2', function () {


console.log('chek2')


return this;


}).addMethod('chek3', function () {


console.log('chek3')


return this;


},true)


methods.chek3();


// methods.chek1();//this[name] = fn;


var m = new methods;//this.prototype[name] = fn;


m.chek3();