最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What's the difference between linting and compiling? - Stack Overflow

programmeradmin5浏览0评论

I know that in Java there is a compiler that tells you when you're writing some wrong code. But Javascript doesn't work that ways, cause it doesn't have a compiler. However, is "linting" javascripts way to compile code?

I know that in Java there is a compiler that tells you when you're writing some wrong code. But Javascript doesn't work that ways, cause it doesn't have a compiler. However, is "linting" javascripts way to compile code?

Share Improve this question edited Oct 4, 2016 at 10:02 sepp2k 370k56 gold badges680 silver badges682 bronze badges asked Oct 3, 2016 at 12:12 R. AndrianaR. Andriana 811 silver badge5 bronze badges 1
  • 1 „But Javascript doesn't work that ways, cause it doesn't have a compiler.” See this en.wikipedia.org/wiki/JavaScript_engine – Adrian Iftode Commented Oct 3, 2016 at 12:22
Add a comment  | 

2 Answers 2

Reset to default 22

Linting is parsing code to verify that the syntax and format are good and follow good practice. A linter will tell you if your indentation is incorrect or if you should be adding spaces around your = operators. A linter could also warn you if your code contains commonly known security flaws or code smells.

Compiling is parsing code to verify that the syntax is correct and convert the code to a different language (generally a faster one).

So what's the difference?

Compiling:

  • syntax validation
  • code converted to different language

Linting:

  • syntax validation
  • style and formatting analysis
  • (optional) code smell/bad code detection
  • (optional) security/performance analysis

Linting is the process of running a program that will analyse code for any errors.

JavaScript Lint holds an advantage over competing lints because it is based on the JavaScript engine for the Firefox browser. This provides a robust framework that can not only check JavaScript syntax but also examine the coding techniques used in the script and warn against questionable practices.

For more information on javascript lint visit http://www.javascriptlint.com/

whereas compiling will run through a code a and will convert it into machine language

发布评论

评论列表(0)

  1. 暂无评论