|
写自己的library 的时候 貌似可以这样用 保护了变量 也能export 函数去外部 欢迎大牛斧正 var out=6; (function(){ var inside=5; alert(out); //showing 6 function show(){ alert("show function") } // use this to export inside function to outside var show2=this.show2=function(){ alert("show 2"); } })(); alert(typeof inside) //undefined show2(); //yes, can be called show(); //undefined [ 本帖最后由 o2h2o 于 2011-7-6 10:56 编辑 ] |