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

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

      1. <tfoot id='tQ4Vs'></tfoot>
      2. <small id='tQ4Vs'></small><noframes id='tQ4Vs'>

        Javascript 中 with 语句的未来

        时间:2024-04-19

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

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

                <legend id='e1w89'><style id='e1w89'><dir id='e1w89'><q id='e1w89'></q></dir></style></legend>
                    <tbody id='e1w89'></tbody>

                  本文介绍了Javascript 中 with 语句的未来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道 with 语句的用法 在 Javascript 中不推荐 并且在 ECMAScript 5 中被禁止,但它允许人们在 Javascript 中创建一些不错的 DSL.

                  I know that usage of the with-statement is not recommended in Javascript and is forbidden in ECMAScript 5, but it allows one to create some nice DSLs in Javascript.

                  例如 CoffeeKup - 模板引擎和 Zappa 网络 DSL.那些使用一些 非常 weird 使用 with 语句的作用域方法来实现 DSLish对他们的感觉.

                  For example CoffeeKup-templating engine and the Zappa web DSL. Those uses some very weird scoping methods with the with-statement to achieve DSLish feeling to them.

                  with 语句和这些类型的 DSL 有没有未来?

                  Is there any future with the with-statement and these kinds of DSLs?

                  如果没有 with 语句,是否可以实现这种 DSL 效果?

                  Can this DSL-effect be achieved without the with-statement?

                  推荐答案

                  with 在 ECMAScript 5 中被禁止"是一种常见的误解.

                  with being "forbidden" in ECMAScript 5 is a common misconception.

                  只有在 ECMAScript 5 的严格模式下——请注意,这是 opt-in——with 语句是语法错误.因此,您当然仍然可以在完全符合 ECMAScript 5 的实现中使用 with,只要它们出现在非严格(或 Crockford 所说的草率)代码中.它的性能不会很好(因为 with 的存在通常会扼杀现代引擎中的各种优化)但它会起作用.

                  Only in strict mode of ECMAScript 5 — which is opt-in, mind you — with statement is a syntax error. So you can certainly still use with in fully ECMAScript 5 -compliant implementations, as long as they occur in non-strict (or sloppy, as Crockford calls it) code. It won't be pretty for performance (since mere presence of with often kills various optimizations in modern engines) but it will work.

                  ECMAScript 的未来版本很可能基于严格模式行为,尽管也可能是可选的.因此,在将来对脚本进行校对时,遵循严格模式当然是一个好主意.

                  Future versions of ECMAScript are very likely to be based on strict mode behavior, although will also likely be opt-in as well. So conforming to strict mode is certainly a good idea when it comes to future proofing your scripts.

                  这篇关于Javascript 中 with 语句的未来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Node.js+Express 和 CoffeeScript 的 IDE 或编辑器 下一篇:如何在 coffeescript 中启用和声语法支持?

                  相关文章

                  <tfoot id='3XaGS'></tfoot>
                • <small id='3XaGS'></small><noframes id='3XaGS'>

                    <legend id='3XaGS'><style id='3XaGS'><dir id='3XaGS'><q id='3XaGS'></q></dir></style></legend>

                    • <bdo id='3XaGS'></bdo><ul id='3XaGS'></ul>

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