简体   繁体   English

为什么 JavaScript IDE 不像编译语言 IDE 那样表示错误?

[英]Why do JavaScript IDEs not denote errors as in compiled language IDEs?

I am curious why, in almost every JavaScript IDEs (like in WebStorm), unresolved variables or types (and any other errors) are just underlined with a light grey line as you can see in the picture.我很好奇为什么在几乎每个 JavaScript IDE(如在 WebStorm 中)中,未解决的变量或类型(以及任何其他错误)只是用浅灰色线下划线,如图所示。

As opposed to this, compiled language IDEs (like CLion) indicates errors with a clearly seen red line showing, that there is something important to recognize.与此相反,编译语言 IDE(如 CLion)用清晰可见的红线指示错误,表明有一些重要的东西需要识别。 I know notations can be modified, but I don't understand the logic behind the default notation.我知道符号可以修改,但我不明白默认符号背后的逻辑。

I also don't know why JavaScript IDEs permit you to run the project, if there are errors.如果出现错误,我也不知道为什么 JavaScript IDE 允许您运行项目。 I suppose, because JS is an interpreted language?我想,因为 JS 是一种解释型语言?

WebStorm 用灰线指示错误

Javascript variables are looked up at runtime. Javascript 变量在运行时查找。 It's entirely possible that your HTML page includes some other 3rd party script, which sets a global variable, which your code then accesses at runtime.您的 HTML 页面完全有可能包含其他一些 3rd 方脚本,该脚本设置了一个全局变量,然后您的代码在运行时访问该变量。 So even though it looks like the variable isn't defined because you didn't define it, it's entirely possible that the variable will exist at runtime and the IDE simply isn't able to trace that statically.因此,即使看起来变量没有定义是因为没有定义它,但该变量完全有可能在运行存在,而 IDE 根本无法静态跟踪它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否有任何 IDE/IDE 插件支持 JavaScript CommonJS 模块? - Do any IDEs/IDE plugins have support for JavaScript CommonJS modules? 跨各种 IDE 的 JavaScript 代码格式标准 - Code formatting standard across various IDEs for JavaScript 哪些 Javascript IDE 可以显示 Three.js 的代码提示? - What Javascript IDEs can display code hints for Three.js? Javascript - 编译语言? - Javascript - Compiled language? 如何使VSCode或WebStorm之类的JavaScript IDE在代码完成方面像Eclipse一样智能? - How to make JavaScript IDEs like VSCode or WebStorm to be as intelligent on code completion as Eclipse? 哪些免费的JavaScript IDE支持用户定义变量的自动补全和“跳转到定义”? - What free javascript IDEs support autocompletion for user defined variables, and “jump to definition”? 关于 IDE 中 node_modules 自动完成的问题 - Question about autocompletion for node_modules in IDEs JavaScript 是编译型还是解释型语言,还是两者兼而有之? - JavaScript is compiled or interpreted language or both? 如果我使用两个不同的IDE打开源代码文件,会有任何冲突吗? - Is there any conflicts if I open a source code file with two different IDEs? 如何在JetBrains IDE中为闭包指定“this”值的类型? - How can I specify the type of the “this” value for a closure in JetBrains IDEs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM