`

<<javascript:the good part>> prototype, closure, module example

 
阅读更多
Function.prototype.method=function(name, func){
this.prototype[name]=func; // use prototype to add a function
return this;
}

String.method("ping",function(content){ // add method to String
var c=content;
return function(){alert(this + content);} // use closure go get the variable
}("kaqi"));  //invoke method in definition

"Hello ".ping()
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics