posts - 195, comments - 34, trackbacks - 0, articles - 1

          JS 函數的使用

          Posted on 2010-07-25 15:38 小強摩羯座 閱讀(197) 評論(0)  編輯  收藏 所屬分類: Java


          1、函數定義和使用

           

          <script>

          function sqrt(x) {
              return x * x;
          }
          function other(f) {
              var y = f(10);
              return y;
          }

          var farr = new Array();
          farr[0] = function(arg) { return arg + arg;};
          farr[1] = function(arg) { return arg * arg;};

          document.write(farr[0](10) + '<br/>');
          document.write(farr[1](10));

           

          document.write(other(sqrt));

          </script>

          sqrt.count = 0;
          sqrt.getcount = function() {
                              return this.count;
                          }; // 附加函式

          //sqrt();
          document.write(sqrt.count, '<br/>');
          document.write(sqrt.getcount());



          主站蜘蛛池模板: 东阿县| 安乡县| 贵州省| 宜兰县| 长沙县| 新晃| 昂仁县| 惠水县| 井冈山市| 新巴尔虎右旗| 郸城县| 广平县| 湖南省| 宁河县| 临泽县| 天等县| 石河子市| 桂林市| 泊头市| 株洲县| 那曲县| 津南区| 新巴尔虎左旗| 宜川县| 奎屯市| 阜宁县| 绍兴市| 永泰县| 开封市| 凯里市| 香格里拉县| 景宁| 合作市| 旬阳县| 怀集县| 晋江市| 基隆市| 太康县| 天祝| 武鸣县| 赤峰市|