【问题标题】:Expected an identifier and instead saw '*'. (E030) [jshint]需要一个标识符,而是看到“*”。 (E030) [jshint]
【发布时间】:2018-10-12 13:53:42
【问题描述】:

我正在制作一个需要数字平方根的函数。 问题是当我尝试使用幂运算符“**”时 Visual Studio Code 给了我错误:

"Expected an identifier and instead saw "*". (E030)"

该操作仍然有效,所以我想知道为什么它甚至会给我一个错误。 我将它与 Math.pow 函数进行了比较,它给出了相同的结果。

let xDist= (x2-x1)**2;
let xDist= Math.pow ((x2-x1),2);

【问题讨论】:

标签: javascript visual-studio-code vscode-settings jshint


【解决方案1】:

我认为您遇到了 jshint 不支持求幂运算符的问题! 现在,您可以忽略带有尾随注释的行,如下所示:

let xDist= (x2-x1)**2; // jshint ignore:line

参考:https://github.com/jshint/jshint/issues/2602

【讨论】:

    猜你喜欢
    • 2019-05-07
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    • 2016-05-19
    • 2014-11-27
    • 2023-03-11
    相关资源
    最近更新 更多