1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        TraceurJavascript 編譯器

        聯(lián)合創(chuàng)作 · 2023-10-02 01:21

        Traceur 是一個來自 Google 的 Javascript 編譯器,通過它可以體驗一些很新并且有趣的 Javascript 語言特性,這些多數(shù)是還沒有被當前瀏覽器實現(xiàn)的 ECMAScript 標準或草案,比如:數(shù)組比較、類、模塊、迭代器、方法參數(shù)默認值、Promise等。

        以下是幾個例子:

        數(shù)組比較(Array Comprehension):

        var array = [for (x of [0, 1, 2]) for (y of [0, 1, 2]) x + '' + y];
        expect(array).to.be.eql([
          '00', '01', '02', '10', '11', '12', '20', '21', '22'
        ]);

        更精簡的函數(shù)定義語法(Arrow Functions):

        var square = (x) => {
          return x * x;
        };
        var square2 = x => x * x;
        var objectify = x => ({ value: x }); // Immediate return of an object literal must be wrapped in parentheses
        expect(square(4)).to.be.eql(16);
        expect(square2(4)).to.be.eql(16);
        expect(objectify(1)).to.be.eql({ value: 1 });

        Promises:

        function timeout(ms) {
          return new Promise((resolve) => {
            setTimeout(resolve, ms);
          });
        }
        timeout(100).then(() => {
          console.log('done');
        });

        更詳細的語言特性列表,請參考:https://github.com/google/traceur-compiler/wiki/LanguageFeatures

        瀏覽 2
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            日韩人妻一区高清 | 国产女人18水真多毛片18 | 韩国中文三级hd字幕 | 男人操女生 | 久久成人 久久鬼色 | 哦┅┅快┅┅用力啊┅美艳后宫 | 影音先锋久久精品视频 | 国产不卡在线 | 国产女同xvideos | 红色A片|