简体   繁体   中英

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.

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. 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. I suppose, because JS is an interpreted language?

WebStorm 用灰线指示错误

Javascript variables are looked up at runtime. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM