guanxf

          我的博客:http://blog.sina.com.cn/17learning

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            71 隨筆 :: 1 文章 :: 41 評論 :: 0 Trackbacks
          function Person(){
            var  age=0;//定義私有成員變量age
            function checkAge(age){
               if(age<0 && age>150){
                   return false;
               }
               return true;
            }
          this.setAge=function(theAge){
            if(checkAge(theAge)){
               age=theAge;    
            }else{
               alert("please input cuerrent age!");
            }
          }
          this.getAge=function(){
               document.write(age);
               return age;
          }
          }
          var per=new Person();
          per.setAge(122);
          per.getAge();
          posted on 2011-12-15 00:56 管先飛 閱讀(1272) 評論(1)  編輯  收藏

          評論

          # re: js封裝屬性和方法 2014-11-10 11:23 21
          213312  回復  更多評論
            


          只有注冊用戶登錄后才能發(fā)表評論。


          網站導航:
           
          主站蜘蛛池模板: 安达市| 长葛市| 洪洞县| 宁强县| 精河县| 山丹县| 高淳县| 萨嘎县| 仙游县| 太康县| 千阳县| 玛多县| 桂阳县| 湘阴县| 正阳县| 大冶市| 平潭县| 稷山县| 康保县| 中牟县| 梁山县| 密云县| 洛扎县| 平乐县| 德清县| 石景山区| 玛沁县| 孟津县| 漾濞| 朝阳市| 乐都县| 两当县| 牙克石市| 敦煌市| 沅江市| 龙州县| 藁城市| 怀来县| 靖宇县| 惠东县| 台北县|