[英]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 是一种解释型语言?
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.