Posted in Javascript onJanuary 18, 2012
//重新封装document对象 var Console={ Write:function(msg){alert(msg);} }; //Person对象 var Person={ _name:"zzl", //static public _age:28, PrintInfo:function(){Console.Write("name:"+Person._name+",age:"+this._age);} //public method ,this表示Person }; // People类型(对象) var People=(function() { var _name="zzl";//private var _age=28; return {//public PrintInfo:function(){Console.Write("name:"+_name+",age:"+_age);} } } ()); Person.PrintInfo();//对象中的方法 People.PrintInfo();//方法对象中的公开子方法 Console.Write(Person._name);//对象中的属性
JS中的public和private对象,即static修饰符
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@