• <bdo id='rz6tY'></bdo><ul id='rz6tY'></ul>
    <tfoot id='rz6tY'></tfoot>

  1. <legend id='rz6tY'><style id='rz6tY'><dir id='rz6tY'><q id='rz6tY'></q></dir></style></legend>

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

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

      如果我使用 const,为什么 JSHint 会发出警告?

      Why does JSHint throw a warning if I am using const?(如果我使用 const,为什么 JSHint 会发出警告?)

      1. <small id='Kqsk4'></small><noframes id='Kqsk4'>

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

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

                <tfoot id='Kqsk4'></tfoot>
              • 本文介绍了如果我使用 const,为什么 JSHint 会发出警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是我在使用 const 时遇到的错误:

                This is the error I get when using const:

                <error line="2" column="1" severity="warning" message="&apos;const&apos; is available in ES6 (use esnext option) or Mozilla JS extensions (use moz)." source="jshint.W104" />
                

                我的代码如下所示:

                const Suites = {
                    Spade: 1,
                    Heart: 2,
                    Diamond: 3,
                    Club: 4
                };
                

                代码运行良好,只有 JSHint 每次都警告我.

                The code works fine only JSHint is warning me every time.

                推荐答案

                当依赖 ECMAScript 6 功能(例如 const)时,您应该设置此选项,以便 JSHint 不会引发不必要的警告.

                When relying upon ECMAScript 6 features such as const, you should set this option so JSHint doesn't raise unnecessary warnings.

                /*jshint esnext: true */(编辑 2015.12.29:更新语法以反映 @Olga 的评论)

                /*jshint esnext: true */ (Edit 2015.12.29: updated syntax to reflect @Olga's comments)

                /*jshint esversion: 6 */
                
                const Suites = {
                    Spade: 1,
                    Heart: 2,
                    Diamond: 3,
                    Club: 4
                };
                

                顾名思义,此选项告诉 JSHint 您的代码使用 ECMAScript 6 特定的语法.http://jshint.com/docs/options/#esversion

                This option, as the name suggests, tells JSHint that your code uses ECMAScript 6 specific syntax. http://jshint.com/docs/options/#esversion

                Edit 2017.06.11:基于this answer添加了另一个选项.

                Edit 2017.06.11: added another option based on this answer.

                虽然内联配置适用于单个文件,但您也可以通过在项目的根目录中创建 .jshintrc 文件并将其添加到其中,为整个项目启用此设置.

                While inline configuration works well for an individual file, you can also enable this setting for the entire project by creating a .jshintrc file in your project's root and adding it there.

                {
                  "esversion": 6
                }
                

                这篇关于如果我使用 const,为什么 JSHint 会发出警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                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 在一年的第一天返回前一年)

                  <tbody id='Lxa0C'></tbody>

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

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

                    <tfoot id='Lxa0C'></tfoot>
                      • <legend id='Lxa0C'><style id='Lxa0C'><dir id='Lxa0C'><q id='Lxa0C'></q></dir></style></legend>

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