jQuery,js如何扩展自定义方法

(jQuery.fn.myMethod=function () {
       alert(myMethod);
})
(function ($) {
        $.fn.extend({
             myMethod : function () {
                  alert(myMethod);
             }
        })
})(jQuery)

 

js String扩展方法

String.prototype.repalceA=function(){

   return this.replace(/a/g,A)
}

‘asdasdasd‘.repalceA()
“AsdAsdAsd”