<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      川山甲

      追求內心的非常平靜!瞬間清空所有的雜念,達到物我兩忘!

        博客園  :: 首頁  ::  :: 聯系 :: 訂閱 訂閱  :: 管理
       
        繼續前兩篇,這篇作為終結篇。
       
      Blocks
       
      ? 有{}的代碼,我們換行處理。
      // bad
      if (test)
        return false;
      
      // good
      if (test) return false;
      
      // good
      if (test) {
        return false;
      }
      
      // bad
      function() { return false; }
      
      // good
      function() {
        return false;
      }

       

      Comments
       
      ? 對于多行注釋使用/**  ... */。包含描述信息、參數類型和返回值。
       
      // bad
      // make() returns a new element
      // based on the passed in tag name
      //
      // @param <String> tag
      // @return <Element> element
      function make(tag) {
      
        // ...stuff...
      
        return element;
      }
      
      // good
      /**
       * make() returns a new element
       * based on the passed in tag name
       *
       * @param <String> tag
       * @return <Element> element
       */
      function make(tag) {
      
        // ...stuff...
      
        return element;
      }

       

      ? 對于單行注釋使用//。單行注釋單獨放置在一個新行上。在注釋前面放置一個空行。
      // bad
      var active = true;  // is current tab
      
      // good
      // is current tab
      var active = true;
      
      // bad
      function getType() {
        console.log('fetching type...');
        // set the default type to 'no type'
        var type = this._type || 'no type';
      
        return type;
      }
      
      // good
      function getType() {
        console.log('fetching type...');
      
        // set the default type to 'no type'
        var type = this._type || 'no type';
      
        return type;
      }

       

      ? 對于一些問題,注釋前加FIXME或TODO,這樣將快速幫助開發者快速明白代碼意圖。

      ? 使用 // FIXME: 注釋問題

      function Calculator() {
      
        // FIXME: shouldn't use a global here
        total = 0;
      
        return this;
      }

      ? 使用 // TODO: 注釋問題的解決方案

      function Calculator() {
      
        // TODO: total should be configurable by an options param
        this.total = 0;
      
        return this;
      }

       

      Type Casting & Coercion
       
      ? 在聲明之前執行強制類型轉換。
      ? 字符串
      //  => this.reviewScore = 9;
      
      // bad
      var totalScore = this.reviewScore + '';
      
      // good
      var totalScore = '' + this.reviewScore;
      
      // bad
      var totalScore = '' + this.reviewScore + ' total score';
      
      // good
      var totalScore = this.reviewScore + ' total score';

       ? 對于數字轉換,使用parseInt,而且要帶著類型轉換的基數。

       ? 如果parseInt成為你的瓶頸,處于性能原因,需要你使用“位移”操作。那么請寫下注釋解釋你這樣做的原因。

      var inputValue = '4';
      
      // bad
      var val = new Number(inputValue);
      
      // bad
      var val = +inputValue;
      
      // bad
      var val = inputValue >> 0;
      
      // bad
      var val = parseInt(inputValue);
      
      // good
      var val = Number(inputValue);
      
      // good
      var val = parseInt(inputValue, 10);
      
      // good
      /**
       * parseInt 使我的代碼變慢.
       * 為了提高速度,使用位移操作讓字符串強制轉化為數字。
       */
      var val = inputValue >> 0;

       ? 布爾

      var age = 0;
      
      // bad
      var hasAge = new Boolean(age);
      
      // good
      var hasAge = Boolean(age);
      
      // good
      var hasAge = !!age;

       

      Constructors
       
       ? 用方法擴展對象,而不是用一個新對象。
      function Jedi() {
        console.log('new jedi');
      }
      
      // bad
      Jedi.prototype = {
        fight: function fight() {
          console.log('fighting');
        },
      
        block: function block() {
          console.log('blocking');
        }
      };
      
      // good
      Jedi.prototype.fight = function fight() {
        console.log('fighting');
      };
      
      Jedi.prototype.block = function block() {
        console.log('blocking');
      };

       

        ? 讓對象的方法return this,這樣有利于方法的鏈鎖操作。
       
      // bad
      Jedi.prototype.jump = function() {
        this.jumping = true;
        return true;
      };
      
      Jedi.prototype.setHeight = function(height) {
        this.height = height;
      };
      
      var luke = new Jedi();
      luke.jump(); // => true
      luke.setHeight(20) // => undefined
      
      // good
      Jedi.prototype.jump = function() {
        this.jumping = true;
        return this;
      };
      
      Jedi.prototype.setHeight = function(height) {
        this.height = height;
        return this;
      };
      
      var luke = new Jedi();
      
      luke.jump()
        .setHeight(20);

        ? 我們可以自定義一個toString()方法。——要確保它能正常運行,而且不會產生其他影響。

      function Jedi(options) {
        options || (options = {});
        this.name = options.name || 'no name';
      }
      
      Jedi.prototype.getName = function getName() {
        return this.name;
      };
      
      Jedi.prototype.toString = function toString() {
        return 'Jedi - ' + this.getName();
      };

       

       

      總結
       
        終于算是寫完了,希望能夠對大家所有幫助。
       
      推薦
       
      posted on 2013-04-24 15:10  川山甲  閱讀(2840)  評論(7)    收藏  舉報
      主站蜘蛛池模板: 亚洲区1区3区4区中文字幕码| 欧美亚洲国产日韩电影在线| 午夜精品区| 99精品热在线在线观看视| 中国女人内谢69xxxx| 不卡国产一区二区三区| 亚洲精品久荜中文字幕| 一本大道久久a久久综合| 亚洲五月丁香综合视频| 男人狂桶女人高潮嗷嗷| a毛片免费在线观看| 国产91精品丝袜美腿在线| 最新亚洲人成网站在线影院| 亚洲国产欧美在线人成AAAA| 亚洲一区精品视频在线| 精品午夜福利无人区乱码| 伊人久久精品无码麻豆一区| 亚洲高清成人av在线| 天天澡日日澡狠狠欧美老妇| 少妇被无套内谢免费看| 免费人成视频网站在线18| 亚洲国产午夜理论片不卡| 国产精品久久久久久无毒不卡 | 国产播放91色在线观看| 尤物yw193无码点击进入| 色一情一区二区三区四区| 精品国产中文字幕在线看| 国产成人精品中文字幕| 国产精品一码二码三码| 国产精品制服丝袜第一页| 看全黄大色黄大片视频| AV人摸人人人澡人人超碰| 无码av波多野结衣| 久久亚洲精品天天综合网| 亚洲欧美人成电影在线观看| 国产成人综合亚洲第一区| 国产亚洲精品久久久久婷婷瑜伽| 国产精品无码专区| 亚洲精品宾馆在线精品酒店| 国产日韩乱码精品一区二区| 欧美成人午夜精品免费福利|