Home  >  Article  >  Web Front-end  >  What are the JS coding standards?

What are the JS coding standards?

php中世界最好的语言
php中世界最好的语言Original
2018-04-13 10:02:032121browse

This time I will bring you what are the JS coding standards and what are the precautions when using JS coding standards. Here are practical cases, let’s take a look.

What is coding specification

Coding standards are a set of standards that guide how to write and organize code. By reading these coding standards, you can get an idea of ​​how code is written in various companies.

Why do we need coding standards

One major reason: everyone writes code differently. I might like to write it one way and you like to write it another way. This is fine if we only deal with our own code. But what if there are thousands of programmers working on a code base at the same time? Without discipline, things can get messy quickly. Code specification allows newcomers to quickly become familiar with the relevant code, and can also write code that is easy for other programmers to understand.

Airbnb JavaScript Style Guide

Claimed to be "the most reasonable way to write JavaScript code."

Airbnb's code specification may be the most popular JavaScript code specification on the Internet. It has 60,000 stars on Github and covers almost every feature of JavaScript.

Address: https://github.com/airbnb/javascript

Google JavaScript Style Guide

A JavaScript source file can be called "Google Style" only if it follows the rules here. It is very domineering and goes its own way, and it is also used by many companies.

Address: https://google.github.io/styleguide/jsguide.html

Idiomatic JavaScript Style Guide

Idiomatic JavaScript code specifications.

No matter how many people are involved, whether they are in the same code base or not, all JavaScript code must be styled as if it was written by the same person.

Another powerful and popular JavaScript coding convention. It also has great ambitions. It not only wants to standardize JavaScript, but also wants to regulate other languages.

Does it look like all the code on the planet was written by the same person? It makes people shudder just thinking about it...

Address: https://github.com/rwaldron/idiomatic.js

JavaScript Standard Style Guide

A powerful JavaScript code specification, with built-in linter and automatic code correction, no configuration required, and automatic code formatting. Low-level errors in the code can be discovered early in the coding process. This code specification is adopted by many well-known companies, such as NPM, GitHub,

mongoDB, etc.

Address: https://github.com/standard/standard

(This Github address is extremely domineering.)

jQuery JavaScript Style Guide

jQuery is a good helper for many people to get started with front-end, but unfortunately now only memories are left. Their specification is considered a very early code specification, mainly stipulating their code and early JavaScript versions.

Address:

https://contribute.jquery.org/style-guide/js/

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other php Chinese websites related articles!

Recommended reading:

JS prompt text box email address completion

$.ajax() method how to retrieve the message from the server Get json data

The above is the detailed content of What are the JS coding standards?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn