<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                >[success] # 帶標簽的模板字符串 ~~~ 1.es6 引入了 模板字符串的寫法'``',同時也引入了'帶標簽的模板字符串' ~~~ >[danger] ##### 了解 ~~~ 1.下面的打印結果發現變成了一個數組 ~~~ ~~~ const str = console.log`hello world` // 打印結果 [ 'hello world' ] ~~~ ~~~ 1.可以看出數組中的項是'插入表達式'作為分割生成的,并且插入表單式中的內容參數,也會依次打印出來 ~~~ ~~~ const name = 'tom' const gender = false const result = console.log`hey, ${name} is a ${gender}.` // 打印結果: [ 'hey, ', ' is a ', '.' ] 'tom' false ~~~ >[danger] ##### 可以做什么 ~~~ 1.下面是一個常見案例,有時候存儲的變量不是實際需要顯示的值往往需要做一下轉換 ~~~ ~~~ const name = 'tom' const gender = false const result = console.log(`hey, ${name} is a ${gender?'男':'女'}.`) // 打印結果: hey, tom is a 女. ~~~ * 如果帶標簽的模板字符串配合定義的function,第一個元素是數組,是被模塊字符串拆分的字符串組合,后面的元素是一個個模塊字符串傳入的內容 ~~~ const name = 'tom' const gender = false function myTagFunc(strings, name, gender) { // console.log(strings, name, gender) // return '123' const sex = gender ? 'man' : 'woman' return strings[0] + name + strings[1] + sex + strings[2] } // result 的返回值是根據函數中定義的返回,如果上面定義的 1 result 打印的變是1 const result = myTagFunc`hey, ${name} is a ${gender}.` // 打印結果: hey,?tom?is?a?woman. console.log(result) ~~~ [mdn中的案例](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/template_strings)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看