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

        <bdo id='VXWiZ'></bdo><ul id='VXWiZ'></ul>
    1. <small id='VXWiZ'></small><noframes id='VXWiZ'>

        <tfoot id='VXWiZ'></tfoot>
      1. <legend id='VXWiZ'><style id='VXWiZ'><dir id='VXWiZ'><q id='VXWiZ'></q></dir></style></legend>
      2. 有什么理由不放弃“var"吗?

        Is there any reason not to abandon quot;varquot;?(有什么理由不放弃“var吗?)
          <bdo id='APiQW'></bdo><ul id='APiQW'></ul>
          • <i id='APiQW'><tr id='APiQW'><dt id='APiQW'><q id='APiQW'><span id='APiQW'><b id='APiQW'><form id='APiQW'><ins id='APiQW'></ins><ul id='APiQW'></ul><sub id='APiQW'></sub></form><legend id='APiQW'></legend><bdo id='APiQW'><pre id='APiQW'><center id='APiQW'></center></pre></bdo></b><th id='APiQW'></th></span></q></dt></tr></i><div id='APiQW'><tfoot id='APiQW'></tfoot><dl id='APiQW'><fieldset id='APiQW'></fieldset></dl></div>

            • <legend id='APiQW'><style id='APiQW'><dir id='APiQW'><q id='APiQW'></q></dir></style></legend>
                  <tbody id='APiQW'></tbody>

                <tfoot id='APiQW'></tfoot>

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

                  本文介绍了有什么理由不放弃“var"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在学习 JavaScript 的过程中,了解到引入 Letconst 是为了解决 Var 关于全局作用域和提升的问题并且如果重新声明也不报错.

                  In the process of learning JavaScript I learned that Let and const were introduced to fix the problems of Var regarding the global scope and hoisting and not giving an error if re-declared.

                  现在我可以在不使用 var 的情况下完全编写代码吗?还是我应该暂时了解它们并等到它们被广泛接受"?

                  Now can I write the code completely without using var ? or should I know about them for now and wait till they becomes widely "acceptable"?

                  也就是说,如果我暂时只使用letconst,我应该担心兼容性问题吗?

                  In other words, for the time being should I be worried about compatibility issues if I only used let and const?

                  推荐答案

                  直接回答这个问题 - 不,你不能,因为兼容性问题,@suraj 好心提醒我们.

                  To answer the question directly - no, you can't, because of the compatibility issues, as @suraj kindly reminded us.

                  话虽如此,在现代 JS 开发中,你越来越不可能使用 var,因为 letconst 具有明显的优势,除了var 的一些特定用途,将使用 BabelJSTypeScript 甚至现在的 Webpack 2 来转换代码向后兼容性,因为生产代码将在 vanilla JS 中提供.现代 IDE,比如 WebStorm,甚至会默认在 ES6 模式下对你的 var 进行 lint,以将它们更改为 let.

                  Having said that, in the modern JS development you are increasingly unlikely to use var as let and const have clear advantages, apart from some specific uses of var and will use either BabelJS, TypeScript or even now Webpack 2 to transpile the code for backward compatibility as the production code will be shipped in vanilla JS. Modern IDEs, like WebStorm, will even lint your var's by default in ES6 mode to change them to let.

                  从问题来看,你还在学习JS,你已经问对了问题,所以我今天推荐使用letconst利用 ES6 的优势,但这会增加处理转译器的复杂性.但是,如果您对此感到满意 - 这就是要走的路.

                  Judging from the question, you are still in the process of studying JS and you are already asking the right questions, so I would recommend to use today let and const to utilize the advantages of ES6, but that would add the complexity of dealing with the transpilers. But if you are OK with that - this is the way to go.

                  这篇关于有什么理由不放弃“var"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社
                  How to use coffeescript in developing web-sites?(如何在开发网站时使用coffeescript?)
                    <tbody id='AXN83'></tbody>

                      • <legend id='AXN83'><style id='AXN83'><dir id='AXN83'><q id='AXN83'></q></dir></style></legend>

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

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

                          • <bdo id='AXN83'></bdo><ul id='AXN83'></ul>