In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "what are the javascript writing specifications", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what are the javascript writing specifications" bar!
General specification file coding
In order to avoid garbled content, use UTF-8 coding to save.
Leave a blank line at the end of the file.
Code detection
Turn on eslint code specification and error checking.
Coding 'use strict'; type specification in strict mode
Js data types include string, number, boolean, null, undefined, array, function and object. Different data types have different storage methods and should not be used. We should pay attention to the following points for data assignment.
The initial value type should be clear.
Do not change types at will
Typeof is preferred for type detection. Object type detection uses instanceof. The detection of null or undefined uses = = null.
The string begins and ends with single quotation marks'... string...'
Naming convention
The variable is named after a small hump, such as addUser password studentID
Constant naming uses all letters of the word in uppercase and separated by an underscore, such as FORM_NAME
Use small hump (camelCase) naming for objects, functions, and instances
/ / object let isObject = {}; / / function function isFun () {...}; / / instance let myBbj = new Object ()
For class naming or constructors, use the big hump name User () DateBase ()
/ / Class class Point {...}; / / Constructor function User (options) {this.name = options.name;} let myBbj = new User ({name: 'yup'}); code specification indentation
Unified use of two space indents, tap indentation is not recommended.
Quotation mark
Uniformly use single quotation marks.
New line
You must wrap at the end of each separate statement.
semicolon
The semicolon at the end of the statement must not be omitted
Code block
Wrap all multiline code blocks with curly braces.
Single-line if statements must also be enclosed in curly braces
/ / recommend if (true) {/ / TODO...} / / do not recommend if (true) / / TODO. Use congruent symbols
Use strictly typed = and! = in the equal sign expression. Implicit type conversions in judgment can be avoided by using =.
/ / recommend if (age = 30) {/ /.} / / do not recommend if (age = = 30) {/ /.} web frontend development LVB tutorial Q-q-u-n: 767273102, with free development tools, zero basics, advanced video tutorials, I hope beginners take fewer detours, annotations, specifications, one-line notes.
Use / / as a single-line comment. Use a single-line comment on another line above the comment object. Insert a space before the comment content.
/ / single-line comment multi-line comment
Start with / * and end with * /, with a space before and after the comments
/ * * first line comment * second line comment * / / * another way of writing * / method comment
Function (method) comments are also a kind of multiline comments, but contain special comment requirements, and key methods must be annotated.
/ * * method function description * @ param {*} Parameter * @ return return value * / TODO comment
Use / / TODO: label the solution to the problem.
Function Calculator () {/ / TODO: total should be configurable by an options param} Thank you for reading, these are the contents of "what are the javascript writing specifications?" after the study of this article, I believe you have a deeper understanding of what the javascript writing specifications have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.