<legend id='jDMQx'><style id='jDMQx'><dir id='jDMQx'><q id='jDMQx'></q></dir></style></legend>
      • <bdo id='jDMQx'></bdo><ul id='jDMQx'></ul>
      <tfoot id='jDMQx'></tfoot>

      <small id='jDMQx'></small><noframes id='jDMQx'>

      <i id='jDMQx'><tr id='jDMQx'><dt id='jDMQx'><q id='jDMQx'><span id='jDMQx'><b id='jDMQx'><form id='jDMQx'><ins id='jDMQx'></ins><ul id='jDMQx'></ul><sub id='jDMQx'></sub></form><legend id='jDMQx'></legend><bdo id='jDMQx'><pre id='jDMQx'><center id='jDMQx'></center></pre></bdo></b><th id='jDMQx'></th></span></q></dt></tr></i><div id='jDMQx'><tfoot id='jDMQx'></tfoot><dl id='jDMQx'><fieldset id='jDMQx'></fieldset></dl></div>

      在 Coffeescript 中迭代 ES6 Set/Map(使用 `of` 运算符)

      时间:2024-04-19

      <small id='tVo8k'></small><noframes id='tVo8k'>

        <tbody id='tVo8k'></tbody>
    1. <tfoot id='tVo8k'></tfoot>

      1. <i id='tVo8k'><tr id='tVo8k'><dt id='tVo8k'><q id='tVo8k'><span id='tVo8k'><b id='tVo8k'><form id='tVo8k'><ins id='tVo8k'></ins><ul id='tVo8k'></ul><sub id='tVo8k'></sub></form><legend id='tVo8k'></legend><bdo id='tVo8k'><pre id='tVo8k'><center id='tVo8k'></center></pre></bdo></b><th id='tVo8k'></th></span></q></dt></tr></i><div id='tVo8k'><tfoot id='tVo8k'></tfoot><dl id='tVo8k'><fieldset id='tVo8k'></fieldset></dl></div>
        1. <legend id='tVo8k'><style id='tVo8k'><dir id='tVo8k'><q id='tVo8k'></q></dir></style></legend>

              • <bdo id='tVo8k'></bdo><ul id='tVo8k'></ul>
                本文介绍了在 Coffeescript 中迭代 ES6 Set/Map(使用 `of` 运算符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何迭代 ES6 Map 或 在Coffeescript中设置?

                在 Javascript 中可以使用例如

                s = new Set()s.add({a: 1})对于 (x of s) {控制台.log(x);}

                但是 Coffeescript 有自己的 of 运算符,可以转换为 in,即:

                console.log(x) for x of s

                变成 ... for (x in s) { ... }.

                如何在 Coffeescript 中访问 Javascript 的 of 运算符?

                可以通过循环s.values().next() 来编写自己的自定义迭代器,但那将是可憎的.:)

                解决方案

                Coffeescript 2.0 —for …from

                <块引用>

                JavaScript 的 for...of 现在可以作为 CoffeeScript 的 for ...from 使用(我们已经有一个 for ...of): for n from generatorFunction()

                Coffeescript 1.0 - 反引号

                一种选择是使用反引号嵌入原始 Javascript,即 http://coffeescript.org/#embedded.

                `for (x of y) { }`

                How can one iterate over an ES6 Map or Set in Coffeescript?

                In Javascript one would use e.g.

                s = new Set()
                s.add({a: 1})
                for (x of s) {
                  console.log(x);
                }
                

                However Coffeescript has its own of operator that gets converted to in, i.e.:

                console.log(x) for x of s
                

                becomes ... for (x in s) { ... }.

                How can one access Javascript's of operator in Coffeescript?

                One could write their own custom iterator by cycling over s.values().next(), but that'd be an abomination. :)

                解决方案

                Coffeescript 2.0 — for …from

                JavaScript’s for…of is now available as CoffeeScript’s for …from (we already had a for …of): for n from generatorFunction()

                Coffeescript 1.0 — Backticks

                One option is to use the backtick to embed raw Javascript i.e. http://coffeescript.org/#embedded.

                `for (x of y) { }`
                

                这篇关于在 Coffeescript 中迭代 ES6 Set/Map(使用 `of` 运算符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  <tbody id='Dc77l'></tbody>
              • <i id='Dc77l'><tr id='Dc77l'><dt id='Dc77l'><q id='Dc77l'><span id='Dc77l'><b id='Dc77l'><form id='Dc77l'><ins id='Dc77l'></ins><ul id='Dc77l'></ul><sub id='Dc77l'></sub></form><legend id='Dc77l'></legend><bdo id='Dc77l'><pre id='Dc77l'><center id='Dc77l'></center></pre></bdo></b><th id='Dc77l'></th></span></q></dt></tr></i><div id='Dc77l'><tfoot id='Dc77l'></tfoot><dl id='Dc77l'><fieldset id='Dc77l'></fieldset></dl></div>

                1. <tfoot id='Dc77l'></tfoot>

                      <legend id='Dc77l'><style id='Dc77l'><dir id='Dc77l'><q id='Dc77l'></q></dir></style></legend>

                      <small id='Dc77l'></small><noframes id='Dc77l'>

                        <bdo id='Dc77l'></bdo><ul id='Dc77l'></ul>